VB.NET Program to Execute a DOS Batch File

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 254
Imports System.Diagnostics

Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim exitCode = -1
Using proc As New Process()
'Set the working directory for the process to be started
proc.StartInfo.WorkingDirectory = "C:\"

'Set the doucment name to start
proc.StartInfo.FileName = "StartAppPool.bat"

'Execute the process

'Wait for the associated process to exit

'Gets the value of the associated process specified when it terminated.
exitCode = proc.ExitCode
End Using

If exitCode = 0 Then
Console.WriteLine("Batch executed successfully")
Console.WriteLine("Some problem happened while executing the batch program")
End If

End Sub
End Class
End Namespace

Comments or Responses

Login to post response