我正在尝试从另一个用户账户名运行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
,它能正常工作吗? - Heinzi