Hard Code Password Question/Passing a Parameter to Console

Hello,
Let me first apploigize as I am sure this question sounds like it is all over the place. I am trying to write a c++ program that will install software on a users PC. The problem that I am having is that the program will not run correctly for a normal user account (in Windows XP, users need elevated privs to install software). Basically, I am using c++ and cmd line arguments to make everything happen.

I have tried to use a runas command, but Windows does not allow you to hardcode passwords into anything (batch files and ect.)

Does anyone know of a way to pass a parameter to the console during runtime...from the program itself? Any thoughts would be appreciated.

In a nutshell, here is what I have so far (Specifics have been removed for security reasons):
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    //VARIABLES
    string path = "net use z: \\\\Server\\Share$\\Folder /user:Domain\\Username Password /persistent:no";
    string application = "RUNAS /user:Domain\\Username \"z:\\application.exe ADDLOCAL=ALL IEXPLORER=1 /quiet\"";
    string pswd = "Password";
    
    //EXECUTED COMMANDS  
    system("title JavaRE Install");
      
    string command1 = path;
    system( command1.c_str() );
    
    string command3 = application;
    system( command3.c_str() );
    
    string command4 = pswd;
    system( command4.c_str() );
}


When my program gets to the "runas" section the console stops and prompts for a password. I would like this password to come straight from my coding and not require any user interaction. Any thoughts or suggestions would be greatly appreciated!
Belongs in the Windows forum, but anyway.
Three choices:
1. Tell your users to install with admin privileges.
2. Install to a user directory instead of a shared directory.
3.
BOOL WINAPI CreateProcessAsUser(
__in HANDLE hToken,
__in LPCTSTR lpApplicationName,
__in LPTSTR lpCommandLine,
__in LPSECURITY_ATTRIBUTES lpProcessAttributes,
__in LPSECURITY_ATTRIBUTES lpThreadAttributes,
__in BOOL bInheritHandles,
__in DWORD dwCreationFlags,
__in LPVOID lpEnvironment,
__in LPCTSTR lpCurrentDirectory,
__in LPSTARTUPINFO lpStartupInfo,
__out LPPROCESS_INFORMATION lpProcessInformation
);
Topic archived. No new replies allowed.