Pages

Sunday, January 30, 2011

Shell and Wait

 ShellandWait("cmd.exe", "/c " + Application.StartupPath + "\Engines\" + temp_Ctr.ToString + "crossparse.bat") 
======================================================
Public Sub ShellandWait(ByVal ProcessPath As String, ByVal Param As String)
   Dim objProcess As System.Diagnostics.Process

        Try
            objProcess = New System.Diagnostics.Process()
            objProcess.StartInfo.FileName = ProcessPath
            objProcess.StartInfo.Arguments = Param
            objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
            objProcess.Start()
            'Wait until the process passes back an exit code
            objProcess.WaitForExit()
            'Free resources associated with this process
            objProcess.Close()
        Catch
            MessageBox.Show("Could not start process " & ProcessPath, "Error")
        End Try
    End Sub

No comments:

Post a Comment