Return value of runas(run as administrator)

How do I get the return value of Run As Administrator. I am using ShellExecute to run cmd as administrator from a c++ program.

How can I tell if the user clicked 'no' or 'yes' in the User Account Control?

This is my code:

1
2
3
4
5
6
7
8
9
10
11
if( ShellExecute(0, "runas", "cmd.exe", "/k color ?", 0, SW_SHOW) == ERROR_SUCCESS )
{
    // some code here to determine if yes or no
    // if( UAC == YES )
   {
       printf("Color help found\n");
       exit(1);
   }
   else
       exit(3);
}
Use ShellExecuteEx and just check its return value.
And how do i do that? It takes only one parameter and returns true/false

Just realized that it returns struct SHELLEXECUTEINFO
Last edited on
Topic archived. No new replies allowed.