【发布时间】:2014-10-25 08:44:53
【问题描述】:
我正在尝试从另一个用户帐户名运行 exe 文件,它显示以下错误
System.ComponentModel.Win32Exception: The requested operation requires an elevation
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
这是我的代码
ProcessStartInfo pro = new ProcessStartInfo(application);
pro.UseShellExecute = false;
pro.Verb = "runas";
pro.WorkingDirectory = workingdirectory;
pro.RedirectStandardInput = true;
pro.RedirectStandardOutput = true;
pro.CreateNoWindow = true;
Process process = Process.Start(pro);
如何解决?
【问题讨论】:
-
我最初的问题是您是否尝试过以管理员身份运行它(您的应用程序)?
-
是的..我只是以管理员身份开始的
-
我记得在某处看到
runas需要UseShellExecute = true。如果将UseShellExecute设置为true是否有效? -
当我将其分配为 true 时,它显示“UseShellExecute 必须为 false 才能以用户身份启动进程
标签: c#