我试图执行一些"netsh"命令,但无论我做什么都会遇到同样的错误:“未找到以下命令:netsh”。
我可以验证路径“C:\Windows\System32\netsh.exe”是有效的,当我通过命令提示符运行相同的命令和参数时,一切正常。
这是我正在使用的代码示例。
我可以验证路径“C:\Windows\System32\netsh.exe”是有效的,当我通过命令提示符运行相同的命令和参数时,一切正常。
这是我正在使用的代码示例。
ProcessStartInfo procInfo = new ProcessStartInfo
{
WorkingDirectory = System.IO.Path.GetPathRoot(System.Environment.SystemDirectory),
FileName = @"netsh.exe",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
Arguments = String.Format(@"{0}\{1} {2}", System.Environment.SystemDirectory, @"netsh.exe", "wlan start hostednetwork"),
WindowStyle = ProcessWindowStyle.Hidden
};
Process proc = Process.Start(procInfo);
proc.WaitForExit();