如何创建运行批处理文件的程序

时间:2016-07-26 14:32:26

标签: visual-studio batch-file cmd

我找到了自动启动wifi热点的批处理文件,所以我需要在visual studio中创建一个程序来运行该批处理文件

Execute batch-file to start wifi hotspot as admin

2 个答案:

答案 0 :(得分:0)

// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "YOURBATCHFILE.bat";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();

代码来自MSDN。

答案 1 :(得分:0)

只需编写包含以下代码行的程序:

System.Diagnostics.Process.Start("c:\\batchfilename.bat");

应该为你的belonings工作。