I need to understand the use of lpEnvironment in CreateProcessAsUser.
I have these two lines of code in my solution which in invoked by a windows service running as Local System.
CreateProcessAsUser(hTokenCpy, null, applicationName, ref saProcess, ref saThread, false, CREATE_UNICODE_ENVIRONMENT, hEnv, null, ref si, out procInfo)
which is called after calling this
CreateEnvironmentBlock(out hEnv, hTokenCpy, false) || hEnv == IntPtr.Zero)
However if the call to CreateProcessAsUser fails.
Another attempt is made by passing hEnv/IpEnvironment = 0
CreateProcessAsUser(hTokenCpy, null, applicationName, ref saProcess, ref saThread, false, 0, IntPtr.Zero, null, ref si, out procInfo
However when the process is created under a specific user name the created process fails to interact with the desktop. Even though the logon user and the user under which the process is running are same.
Is this because the process is getting created under the memory block of the Windows service instead of the logged on User ?