我有以下代码:
// Creating procesStartInfo obj
System.Diagnostics.ProcessStartInfo procStartInfo
= new System.Diagnostics.ProcessStartInfo();
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
//Window state hidden .. so black windows will come inbetween
procStartInfo.WindowStyle
= System.Diagnostics.ProcessWindowStyle.Hidden;
// Creating Process obj to run the net time cmd
System.Diagnostics.Process p;
string output;
p = new System.Diagnostics.Process();
p.StartInfo = procStartInfo;
p.StartInfo.FileName = "w32tm";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.Arguments = " /resync /computer:xxxxx977";
p.Start();
p.WaitForExit();
output = p.StandardOutput.ReadLine().ToString();
MessageBox.Show(output);
当我执行此代码时,我收到一条错误消息:
发生以下错误:找不到指定的模块。(0x8007007E)。
如果我远程或本地运行命令w32tm /resync /computer:xxxxx977
,它工作正常。为什么在使用代码而不是从命令行启动进程时会出现此错误?