C到管理员#如何运行一个进程(带参数)升高CMD进程、管理员、参数、CMD

由网友(獣潮:ORgASM.)分享简介:ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " +"processNeedToRun"){RedirectStandardError = true,RedirectStandardOutput = true,UseShellExec...
ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " +"processNeedToRun")
{
    RedirectStandardError = true,
    RedirectStandardOutput = true,
    UseShellExecute = false,
    CreateNoWindow = true,
    Verb ="runas"
};

我用上面的code通过cmd,在C#中运行一个进程。

I use the above code to run a process through cmd in C#.

不过,问题是:

在processNeedToRun运行时需要的参数。 即使我设置动词=运行方式时,Windows 7仍然提示了迅速提升对话框。

是否有可能满足所有要求?

Is it possible to meet all the requirements?

推荐答案

如果是这样的启动进程 processNeedToRun 不升高,再有就是没有办法避免在提升对话框。这样做将是一个安全漏洞。所以,你只是将不得不忍受的提升提示。

If the process that's launching processNeedToRun is not elevated, then there is no way to avoid the elevation dialog. Doing so would be a security hole. So you're just going to have to live with the elevation prompt.

添加参数 processNeedToRun 是没有问题的,但。您可以将它们只是添加到您传递给的ProcessStartInfo 参数:

Adding arguments to processNeedToRun is no problem, though. You can just add them to the arguments you pass to ProcessStartInfo:

var procStartInfo = new ProcessStartInfo("cmd", "/c processNeedToRun arg1 arg2");
阅读全文

相关推荐

最新文章