C#的服务程序如何执行cmd或bat文件?如何执行dos命令
C#的windows服务程序如何执行cmd或bat文件,试了各种方法都不行;
System.Diagnostics.Process.Start(@"D:\Start_VM.bat");
这种不行;
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + command;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = false;
p.Start();
outputMsg = p.StandardOutput.ReadToEnd();
p.Close();
这样也不行;
在应用程序中可以,但是到windows服务程序中就不可用了