Process.Start()不在同一用户下生成新进程 [英] Process.Start() not spawning new process under the same user

查看:79
本文介绍了Process.Start()不在同一用户下生成新进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是给人一种印象,当您以(domain 的身份运行进程时,使用 Process.Start(),它将使用相同的凭据- mydomain\myuser 来启动此新过程。

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.

我遇到的问题是我的 Process.Start()调用似乎正在SYSTEM帐户下创建一个进程,这导致了我的权限问题在已启动的进程中(由于其工作原因,该进程必须在管理员帐户下运行)。如果它改变了-我正在Windows安装程序中从生成此过程(自定义的exe)。

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.

有什么建议吗?我已经读过有关Windows组策略(可能)对此产生影响的信息,但是老实说,它对我来说是个迷路。

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.

编辑:一段代码:

其中 exename commandLine 是此方法的参数正文:

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;


推荐答案

将procInfo.UseShellExecute设置为true,或者执行cmd作为您的exe作为cmd命令参数的进程。当UseShellExecute设置为false时,会有很多有趣的副作用: UseShellExecute

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

这篇关于Process.Start()不在同一用户下生成新进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆