C#执行bat文件


1.新建一个bat文件

2.cmd命令写入bat文件中

例如:(功能是停止MySQL服务)

net stop MySQL

net start MySQL

c#代码:

 Process proc = new Process();
 string targetDir = string.Format(@"D:\bat\");

 proc.StartInfo.WorkingDirectory = targetDir;
 proc.StartInfo.FileName = "servicerestart.bat";
 proc.StartInfo.Arguments = string.Format("10");
 
 proc.Start();
 proc.WaitForExit();

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM