简体   繁体   中英

Process.Start() not spawning new process under the same user

I was always under the impression that when you're running a process as (domain\\user) mydomain\\myuser , when using Process.Start() it would start this new process using the same credentials - mydomain\\myuser .

The issue I'm having is that my Process.Start() call seems to be creating a process under the SYSTEM account which is causing me permission issues in the started process (which must run under an admin account due to the work it does). If it changes things - I'm spawning this process (a custom built exe) from within a windows installer .

Any suggestions? I've read about windows group policies (possibly) having an impact on this, but if I'm honest, it's lost on me.

EDIT: a little snippet:

Where exename and commandLine are parameters for this method body:

ProcessStartInfo procInfo = new ProcessStartInfo(exeName, commandLine);
procInfo.WorkingDirectory = workingDirectory;
procInfo.UseShellExecute = false;
procInfo.CreateNoWindow = true;
Process process = Process.Start(procInfo);
Process.WaitForExit();
return process.ExitCode;

Either set procInfo.UseShellExecute to true, or execute cmd as a process with your exe as a parameter to the cmd command. When UseShellExecute is set to false, here are a lot of interesting side effects: UseShellExecute

Your impression is true. Process.Start() will always start the new process under current user's credentials - unless you provide alternative credentials in the ProcessStartInfo or use one of the overloads that take credentials.

There must be another problem - share a snippet of your code.

UPDATE

OK! You did not mention anything about installer. All MSI installers will be running under system since they will be run by " Windows Installer " which you can check and they run under SYSTEM .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM