windows - example code: A service calls CreateProcessAsUser() I want the process to run in the user's session, not session 0 -


I am getting the example code:

CreateProcessAsUser () for a service call In the user session you want to run, session 0 does not

The process created so far is just like a service in session 0

< Div class = "post-text" itemprop = "Text">

This was stripped from some old code that launched the console app from the service. It worked under NT4, but I did not test it with a modern version of Windows, so it can not guarantee that it works on NT4.

EDIT: No, it is not going to work. You need to set up the code found to create a desktop, add SID etc.

  (Logon user (user ID, domain, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, and amp; hUserToken)) {return GetLastError (); } If (! ImpressNet Logged Onuser (Aututteroken)) {DWORD rc = GetLastError (); CloseHandle (hUserToken); Return RC; } STARTUPINFO C; PROCESS_INFORMATION pi; Memes (& amp; si, 0, size (SI)); Memset (and p, 0, sizaf (pi)); Si.cb = Size (C); RC = CreateProcessAsUser (hUserToken, // user token 0, // app name "foo.exe", // command line 0, // process attributes 0, // thread attributes false, do not have the right to handle DETACHED_PROCESS , / / ​​Flags 0, // Environment Block 0, // Current Dior & SI, // Startup Info and PI); // Process information is kept here (! Rc) {DWORD rc = GetLastError (); RevertToSelf (); CloseHandle (hUserToken); Return RC; } Revertosoul (); CloseHandle (hUserToken); Return 0;    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -