Public Sub RunApplication(ByVal filePath As String, ByVal args As String, ByVal waitForExit As Boolean, ByVal setWorkingDirectoryToPath As Boolean)
Dim processStartInfo As New ProcessStartInfo(filePath, String.Format(" {0}", args))
processStartInfo.UseShellExecute = False
processStartInfo.RedirectStandardOutput = False
processStartInfo.CreateNoWindow = False
If (setWorkingDirectoryToPath) Then
processStartInfo.WorkingDirectory = Path.GetDirectoryName(filePath)
End If
RunProcess(processStartInfo, waitForExit)
End Sub
Private Sub RunProcess(ByVal processInfo As ProcessStartInfo, ByVal waitForExit As Boolean)
Using process As New Process()
process.StartInfo = processInfo
process.Start()
If (waitForExit) Then
process.WaitForExit()
End If
End Using
End Sub