我有一个.net控制台在Windows 7中工作得很好但是出于某种原因,如果我在Windows XP中运行相同的代码,我收到错误信息“没有进程与此对象关联”,然后它指向到prc.WaitForExit();
代码如下:
string path;
path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
Process prc = new Process();
prc.StartInfo.FileName = path + "\\Process2.bat";
prc.Start();
prc.WaitForExit();
System.Threading.Thread.Sleep(10);
Console.WriteLine("{0} Task Process2 completed with process ID {1} and return code {2}. ", DateTime.Now.ToString(), prc.Id, prc.ExitCode.ToString());
System.IO.StreamWriter file =
new System.IO.StreamWriter(logpath + "\\logfile.txt", true);
file.WriteLine(DateTime.Now.ToString() + " Task Process2 completed with process ID " + prc.Id + " and return code " + prc.ExitCode.ToString());
file.Close();
请帮忙。任何帮助都非常适合。