开发者

Run batch file in vb.net?

开发者 https://www.devze.com 2022-12-18 13:20 出处:网络
How can I run a batch from from within开发者_StackOverflow vb.net? You can use the Process class to run a batch file

How can I run a batch from from within开发者_StackOverflow vb.net?


You can use the Process class to run a batch file

Dim psi As New ProcessStartInfo("Path TO Batch File")
psi.RedirectStandardError = True
psi.RedirectStandardOutput = True
psi.CreateNoWindow = False
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.UseShellExecute = False

Dim process As Process = Process.Start(psi)


Here is a simple and straight forward method:

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


The best way is to use the Process.Start and pass the path to the batch file

Process.Start(pathToBatchFile)


The easiest way if you know the exact location of the file is

System.Diagnostics.Process.Start("c:\test\file.bat")

In Visual Studio the file must exist in the /bin/debug or /bin/release depending on your current build configuration

System.Diagnostics.Process.Start("test.bat")
0

精彩评论

暂无评论...
验证码 换一张
取 消