【发布时间】:2011-09-30 13:00:56
【问题描述】:
这是我的代码:
try
{
ProcessStartInfo procStartInfo = new ProcessStartInfo(
"cmd.exe",
"/c " + command);
procStartInfo.UseShellExecute = true;
procStartInfo.CreateNoWindow = true;
procStartInfo.Verb = "runas";
procStartInfo.Arguments = "/env /user:" + "Administrator" + " cmd" + command;
///command contains the command to be executed in cmd
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
我想保留
procStartInfo.UseShellExecute = true
procStartInfo.RedirectStandardInput = false;
是否可以不使用process.standardinput 执行命令?
我尝试执行我传入参数的命令,但该命令没有执行。
【问题讨论】:
-
是否可以不使用 process.standardinput 来执行命令?我尝试执行我传入参数的命令,但该命令没有执行。您目前没有使用它,所以这个问题没有多大意义。请帮助您的用户,让命令提示符可见,以便他们知道发生了什么。
-
你不想要
Verb。这并不意味着你认为它意味着什么。我想。 -
@Ramhound procStartInfo.Arguments = "/env /user:" + "管理员" + " cmd" + 命令;
-
@mtijn 是的,它在那一点上失败了。所以我想知道是否可以通过其他方式给出命令
标签: c# .net command-line process privileges