M
Marino Borra
Guest
Hi to all,
I have a problem with the CreateProcessAsUserW function called from a service that run as Local System on a terminal server.
If I run the following snippet the regedit.exe will be execute correctly on the desktop of the user:
char text[] = "C:\\windows\\regedit.exe";
wchar_t wtext[MAX_PATH];
std::mbstowcs(wtext, text, strlen(text)+1);
LPWSTR ptr = wtext;
// Start the process on behalf of the current user
BOOL result = CreateProcessAsUserW( hUserToken,
NULL,
ptr,
NULL,
NULL,
FALSE,/* On Terminal Server MUST be FALSE */
/*CREATE_NO_WINDOW*/ CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT,
lpEnvironment,
NULL,
&StartupInfo,
&ProcessInfo);
Bui if I change the command line:
char text[] = "C:\\windows\\system32\\cmd.exe /C C:\\runner\\launch.bat";
I see a black windows for a fraction of second but the batch doesn't start. The launch.bat contains only a pause command.
The GetExitCodeProcess reports :[1]
The same result with:
char text[] = "C:\\windows\\system32\\cmd.exe";
Help please.
Thanks
Continue reading...
I have a problem with the CreateProcessAsUserW function called from a service that run as Local System on a terminal server.
If I run the following snippet the regedit.exe will be execute correctly on the desktop of the user:
char text[] = "C:\\windows\\regedit.exe";
wchar_t wtext[MAX_PATH];
std::mbstowcs(wtext, text, strlen(text)+1);
LPWSTR ptr = wtext;
// Start the process on behalf of the current user
BOOL result = CreateProcessAsUserW( hUserToken,
NULL,
ptr,
NULL,
NULL,
FALSE,/* On Terminal Server MUST be FALSE */
/*CREATE_NO_WINDOW*/ CREATE_NEW_CONSOLE | NORMAL_PRIORITY_CLASS | CREATE_UNICODE_ENVIRONMENT,
lpEnvironment,
NULL,
&StartupInfo,
&ProcessInfo);
Bui if I change the command line:
char text[] = "C:\\windows\\system32\\cmd.exe /C C:\\runner\\launch.bat";
I see a black windows for a fraction of second but the batch doesn't start. The launch.bat contains only a pause command.
The GetExitCodeProcess reports :[1]
The same result with:
char text[] = "C:\\windows\\system32\\cmd.exe";
Help please.
Thanks
Continue reading...