Thursday, March 24, 2016

VB.NET - Execute Command Lines

To call a command prompt in one line, it can be done this way:

Process.Start("cmd", "/c cd " & m_strSignToolLocation & " & " & strSignCmd)

To call a command prompt with more options, such as running with the command prompt hidden, call this way:

Dim p As Process = New Process()
Dim pi As ProcessStartInfo = New ProcessStartInfo()
pi.Arguments = "/c cd " & m_strSignToolLocation & " & " & strSignCmd
pi.FileName = "cmd.exe"
pi.WindowStyle = ProcessWindowStyle.Hidden

p.StartInfo = pi

p.Start()

Here are what some of the command arguments mean:

'/k returns the command window
'/c terminates the command window

'& allows multi line execution on a single line