我如何从c#.net中的Windows服务器运行bat文件 [英] how can i run a bat file from windows server in c#.net
本文介绍了我如何从c#.net中的Windows服务器运行bat文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
如何从c#.net中的Windows服务器运行bat文件
谢谢
Sudheer.N
Hi all ,
how can i run a bat file from windows server in c#.net
Thanks
Sudheer.N
推荐答案
如果我正确理解了您的问题,则可以使用
If I understand your question correctly you can use
Process.Start(pathToYourBatFile);
您可以在此处阅读有关其的代码项目文章: ^ ]
You can read a codeproject article about it here : Run Interactive Command Shell or Batch Files From ASP.NET[^]
您可以使用下面的代码
字符串BatchFilePath ="D:\\ scripts \\ batchfile1.bat";
如果(File.Exists(BatchFilePath))
{
System.Diagnostics.Process proc =新的System.Diagnostics.Process();
proc.StartInfo.FileName = BatchFilePath;
proc.StartInfo.RedirectStandardError = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
}
:)
You can use the below code
String BatchFilePath = "D:\\scripts\\batchfile1.bat";
if (File.Exists(BatchFilePath))
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = BatchFilePath;
proc.StartInfo.RedirectStandardError = false;
proc.StartInfo.RedirectStandardOutput = false;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.WaitForExit();
}
:)
这篇关于我如何从c#.net中的Windows服务器运行bat文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文