Tech Support > Microsoft Windows > Development Resources > CreateProcessWithLogonW without UAC popup in Vista
CreateProcessWithLogonW without UAC popup in Vista
Posted by ashu.nitc@gmail.com on May 8th, 2008


Hi ,

I am trying to create process using CreateProcessWithLogonW() API.
This works fine on Win2000 and NT, but in Vista it gives a UAC popup
before the process (say, notepad, calc, etc) kicks off.

This is the sample program that I am compiling on .NET

/* START OF PROGRAM */

#define UNICODE
#define _WIN32_WINNT 0x0500
#include <userenv.h>
#include <windows.h>

void wmain(int argc, WCHAR *argv[])
{
DWORD dwFlags=0;
PROCESS_INFORMATION pi={0};
STARTUPINFOW si={0};
SecureZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
dwFlags = CREATE_UNICODE_ENVIRONMENT;
if(!CreateProcessWithLogonW(L"administrator", L"UJMO6506-2KS-5",
L"Test0000", LOGON_WITH_PROFILE, NULL, argv[1], dwFlags, NULL, NULL,
&si, &pi))
printf("\nExecuted CreateProcess with error code=[%d]",
GetLastError());
else
printf("The pid of the process=[0x%x]", pi.dwProcessId);
}

/* argv[1] is the tool that I want to run (eg: notepad) */
/* END OF PROGRAM */

Could someone please suggest me how to use this API so that I do not
get the vista UAC popup?
Disabling the UAC on the OS is not an option for me.

Many thanks in advance,
Ashish

Posted by Sebastian G. on May 8th, 2008


ashu.nitc@gmail.com wrote:



There is none, such an action simply has to invoke UAC.


Why not? After all, you cannot expect your program to work on Vista anyway.