本文介绍了请求的操作需要提升的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试从另一个用户帐户名运行exe文件,它显示以下错误
I am trying to run an exe file from another user account name, it shows following error
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);
如何解决这个问题?
推荐答案
不幸的是,你不能做
- 以提升的权限运行,并且
- 重定向输入/输出
同时.
原因:
- 仅在
-
动词
,但是 - 重定向IO需要
UseShellExecute = false
.
UseShellExecute = true
时识别Verb
is only recognized whenUseShellExecute = true
, but- redirecting IO requires
UseShellExecute = false
.
更多信息:
我想在您的情况下,您将不得不使用 runas
跳过,而是要确保您的应用程序已使用正确的用户帐户/权限启动.这应该可行,因为由提升的进程启动的进程继承"了海拔.
I guess in your situation you will have to skip using runas
, but rather ensure that your application is already started with the correct user account/permissions. This should work, since processes started by elevated processes "inherit" elevation.
这篇关于请求的操作需要提升的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!