Pause / wait * .bat to complete VB.net

I need to pause / wait for the next VB program between arorasTEMP.bat and "Label2.Text =" Append for AutoCAD version A ... ", because this happens when a bit is added before a temporary copy is created

    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 an example?

+3
source share
2 answers

Shell is a VB6 team; it is not an ideal way to start processes.

The correct way in .NET to call a process and wait for it:

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 force kill him if it takes too long:

If Not aroras.WaitForExit(300) Then
   aroras.Kill()
End If

(where 300 is the timeout in milliseconds)

+4
source

you can tell the shell to wait for the process to complete before doing anything else:

RetBat1 = Shell("C:\VTS\arorasTEMP.bat", ,True) 

-, , , 6 :

RetBat1 = Shell("C:\VTS\arorasTEMP.bat", , True, 6000) 

Shell: http://msdn.microsoft.com/en-us/library/xe736fyk(VS.80).aspx

+1

Source: https://habr.com/ru/post/1773847/


All Articles