是否在vb.net中运行批处理文件?
如何从vb.net中运行批处理 最好的方法是使用是否在vb.net中运行批处理文件?,vb.net,Vb.net,如何从vb.net中运行批处理 最好的方法是使用过程。启动并传递批处理文件的路径 Process.Start(pathToBatchFile) Dim psi As New ProcessStartInfo("Path TO Batch File") psi.RedirectStandardError = True psi.RedirectStandardOutput = True psi.CreateNoWindow = False psi.WindowStyle = ProcessWind
过程。启动并传递批处理文件的路径
Process.Start(pathToBatchFile)
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)
简单直接法
System.Diagnostics.Process.Start(“c:\batch.bat”)您可以使用Process类运行批处理文件
Process.Start(pathToBatchFile)
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)
'如果您知道文件的确切位置,最简单的方法是
System.Diagnostics.Process.Start(“c:\test\file.bat”)
'在Visual Studio中,该文件必须存在于/bin/debug或/bin/release中,具体取决于当前的生成配置
System.Diagnostics.Process.Start(“test.bat”)谢谢,最好也添加psi.WorkingDirectory=“PATh to Dir”。