我想通过VB运行一个批处理文件,我需要等待它完成/退出前进度。我相信我遇到的问题是,当执行批处理文件时,它会打开cmd.exe而不是批处理文件。在继续之前等待批处理文件关闭 - VB.net
这是我用VB
My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath & "\PingCheck\machines.txt")
FileCopy(My.Application.Info.DirectoryPath & "\machines.txt", My.Application.Info.DirectoryPath & "\PingCheck\machines.txt")
Dim psi As New ProcessStartInfo(My.Application.Info.DirectoryPath & "\PingCheck\go.bat")
psi.RedirectStandardError = True
psi.RedirectStandardOutput = True
psi.CreateNoWindow = False
psi.WindowStyle = ProcessWindowStyle.Hidden
psi.UseShellExecute = False
Dim process As Process = process.Start(psi)
process.WaitForExit()
ProgressBar1.Value = ProgressBar1.Value + 2
FileCopy(My.Application.Info.DirectoryPath & "\PingCheck\machines.txt", My.Application.Info.DirectoryPath & "\machines.txt")
'My.Computer.FileSystem.DeleteFile(My.Application.Info.DirectoryPath & "\ping.bat")
MsgBox("Ping Check Complete")
遇到的问题即时执行的是,它会直接删除ping.bat完成之前。
如何从我调用的批处理文件中监控进程。然后一旦退出,继续使用脚本?
谢谢,但我不相信这是工作。 我已经调整了我的脚本来匹配这个,但它仍然显示MessageBox之前它似乎已经完成。看到第一篇文章 – K20GH 2012-02-01 13:17:20
为什么不呢?你认为哪部分不起作用? – 2012-02-01 13:19:05
我告诉它运行\ PingCheck \ go.bat,并在它完成之前显示消息框。 go.bat实际上运行并设置了一个ping测试循环,所以它不会关闭,直到这些完成 – K20GH 2012-02-01 13:22:19