responding to system prompt?
I'm having trouble figuring out how to respond to a system prompt in a console application.
I need to run a setup.exe on users PCs under the admin context.
If I do something like:
system("runas /user:computername\administrator setup.exe");
the system then prompts me with:
"enter password for administrator"
I thought I could send the password to the keyboard buffer, but the problem is that the console app stops processing until a response is typed at the command prompt.
I'm not sure how to get around this. I used to use su, which allows you to supply a password as a parameter but microsoft has taken this functionality away with runas.
Any help appreciated.
using CreateProcessAsUser and LogonUser
OK so I'm trying to use CreateProcessAsUser and LogonUser but I'm having problems with the Process_Information and StartupInfo structs that CreateProcessAsUser uses.
I've included Winbase.h and Windows.h but when I try to declare a struct of either type, I get a message:
"error C2079: 'P_INFO' uses undefined struct 'PROCESS_INFORMATION' "
However, If I try to typedef the struct myself I get an error:
error C2371: 'STARTUPINFO' : redefinition; different basic types
c:\program files\microsoft visual studio\vc98\include\winbase.h(3818) : see declaration of 'STARTUPINFO'
So it seems to see the struct in winbase.h after all. I'm not sure whats happening here.