How can I run another application or batch file from my Visual Basic .NET code?
Posted by: Duncan Mackenzie, MSDN This post applies to Visual Basic .NET 2002/2003 Suppose you want to run a command line application, open up another Windows program, or even bring up the default web browser or email program… how can you do this from your VB code? The answer for all of these examples is the same, you can use the classes and methods in System.Diagnostics.Process to accomplish these tasks and more. Example 1. Running a command line application, without concern for the results: Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click System.Diagnostics.Process.Start(“C:\listfiles.bat”) End Sub Example 2. Retrieving the results and waiting until the process stops (running the process synchronously): Private Sub Button2_Click(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Button2.Click Dim psi As New _ System.Diagnostics.ProcessStartInfo(“C:\listfiles.bat”) psi.RedirectStandardOutput = True psi.WindowSt
Posted Sun, May 30 2004 by vbfaq 15 Comments Posted by: Duncan Mackenzie , MSDN This post applies to Visual Basic .NET 2002/2003 Suppose you want to run a command line application, open up another Windows program, or even bring up the default web browser or email program… how can you do this from…
Related Questions
- Why am I receiving Run Application Error, "File Not Found:C:Program FilesMicrosoft DynamicsGPDRMSRS.exe..." when trying to print a SRS report?
- Does the bridge run native code within my servlet engine or application server?
- How can I run another application or batch file from my Visual Basic .NET code?