hi i need to pause/ wait the bellow VB program between the arorasTEMP.bat and the "Label2.Text = "Appending for AutoCAD version A..." as it happens the bat is appending before its temp copy is made
Dim RetBat1
RetBat1 = Shell("C:\VTS\arorasTEMP.bat", 1)
Label2.Text = "Appending for AutoCAD version A..."
'Appending the acad2011.lsp
If System.IO.File.Exists(FILE_NAME1) = True Then
Dim objWriter As New System.IO.StreamWriter(FILE_NAME1, True)
objWriter.WriteLine(arorasKEY)
objWriter.Close()
End If
can anyone give example?
Shell is a VB6 command, it's not the ideal way to launch processes.
The proper way in .NET to invoke a process and wait for it is:
Dim aroras as Process = Process.Start("C:\VTS\arorasTEMP.bat")
aroras.WaitForExit()
' error code is available in aroras.ExitCode, if you need it
You can also forcibly kill it if it takes too long:
If Not aroras.WaitForExit(300) Then
aroras.Kill()
End If
(where 300 is the time in milliseconds to wait)
you can tell the shell to wait for the process to be done before executing anything else:
RetBat1 = Shell("C:\VTS\arorasTEMP.bat", ,True)
And even give a timeout that stops the execution if it takes too long, in this case 6 seconds:
RetBat1 = Shell("C:\VTS\arorasTEMP.bat", , True, 6000)
More info about the Shell function: http://msdn.microsoft.com/en-us/library/xe736fyk(VS.80).aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With