ste*_*far 7 c# command-line cmd shellexecute command-line-arguments
我需要通过c#传递多个命令行参数,用于名为handle.exe的进程:http://www.google.com.mt/search? sourceid = chrome&ie = UTF-8&q = handlele.exe
首先,我需要通过ADMINISTRATOR权限运行可执行文件.这篇文章帮助我实现了这一点:以 编程方式在cmista中运行cmd.exe作为管理员,c#
但接下来是调用实际行参数的下一个问题,例如"-p explore"
如何一起指定命令行参数,或者可以连续指定?
目前的代码如下:
Process p = new Process();
ProcessStartInfo processStartInfo = new ProcessStartInfo("filePath");
processStartInfo.CreateNoWindow = true;
processStartInfo.UseShellExecute = false;
processStartInfo.RedirectStandardOutput = true;
processStartInfo.RedirectStandardInput = true;
processStartInfo.Verb = "runas";
processStartInfo.Arguments = "/env /user:" + "Administrator" + " cmd";
p.StartInfo = processStartInfo;
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
Console.WriteLine(output);
Run Code Online (Sandbox Code Playgroud)
谢谢
您可以使用 UseShellExecute 命令运行该进程并传入用户名和密码
尽管您将在某处存储用户名和密码。