Problem:
(1) On a Windows 2008 R2 x64 system server
(2) a1.exe works as user u1, calls the CreateProcess () API with dwCreationFlags = 0 to run a2.exe.
(3) a2.exe calls the CreateProcessAsUser () API with dwCreationFlags = CREATE_BREAKAWAY_FROM_JOB | CREATE_SUSPENDED to run powershell.exe as user u2
(4) a1.exe calls a2.exe 5 times
(5) command-line powershell is "powershell.exe -command echo Hi"
(6) Only the 1st powershell process was successful and returned the "Hi" output in a1.exe and with exit code 0
(7) All other (2 to 5) powershell processes did not work with exit code 1
Correction:
(1) a2.exe, API CreateProcessAsUser() dwCreationFlags = CREATE_BREAKAWAY_FROM_JOB | CREATE_SUSPENDED | CREATE_NO_WINDOW, powershell.
, :
(1) powershell - , , a2.exe .
(2) 5 , a1.exe, 5 a2.exe 5 powershell.exe , a1.exe
(3) powershell a2.exe , powershell.
(4) pre-vista (xp, 2003 ..) - powershell 5 CREATE_NO_WINDOW.
:
, post-vista (2008, 7, 8) powershell , . ( , powershell (CREATE_NO_WINDOW) (CREATE_NEW_CONSOLE) (DETACHED_PROCESS).
:
, . powershell post-vista, w.r.t.
Madhukiran