在vb.net中运行批处理文件?

Ale*_*lex 9 vb.net

如何从vb.net中运行批处理?

RHi*_*cke 19

您可以使用Process类来运行批处理文件

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)
Run Code Online (Sandbox Code Playgroud)

  • 谢谢,最好添加psi.WorkingDirectory ="PATh TO Dir". (3认同)

Viv*_*ard 6

简单直接的方法

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