2010-02-01 43 views

Trả lời

18

Bạn có thể sử dụng lớp Process để chạy một tập tin batch

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) 
+3

Cảm ơn, Nó tốt hơn để thêm psi.WorkingDirectory = "path ĐỂ Dir "là tốt. –

1

Cách tốt nhất là sử dụng Process.Start và vượt qua đường dẫn đến tập tin thực thi

Process.Start(pathToBatchFile) 
6

đơn giản và thẳng về phía trước phương pháp

System.Diagnostics.Process.Start ("c: \ batch. dơi ")

0

'Cách đơn giản nhất nếu bạn biết chính xác vị trí của tập tin là

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

' Trong Visual Studio file phải tồn tại trong thư mục/bin/debug hoặc/bin/release tùy thuộc vào xây dựng cấu hình hiện tại của bạn

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

Các vấn đề liên quan