0

I can't change directory from C:\ to C:\Apps\app.exe in single execution. Cmd doesn't allow me to do it. I want to execute C:\Apps first then, execute app.exeargument in order to open app.exe using Process.Start() that opens cmd.exe in a single run. Here is my code.

Dim FullPath As String = "C:\Apps\app.exe"
Dim appPath As String = "C:\Apps"
Dim appName As String = "app.exe"
Dim p As Process = Process.Start("cmd.exe", "/k cd " + appPath)
'Don't know what to do here...

My output should be like this:
Cmd

Master James
  • 318
  • 5
  • 18

1 Answers1

0

Thanks to @Babbillumpa i've solved my problem:

Dim _processStartInfo As ProcessStartInfo = New ProcessStartInfo()
        _processStartInfo.WorkingDirectory = appPath
        _processStartInfo.FileName = "cmd.exe"
        _processStartInfo.Arguments = "/k app.exe"
        _processStartInfo.CreateNoWindow = True

        Dim myProcess As Process = Process.Start(_processStartInfo)
        'wait for specific time for the thread to be closed
        myProcess.WaitForExit(500)

        ' Close process by sending a close message to its main window.
        myProcess.CloseMainWindow()
        ' Free resources associated with process.
        myProcess.Close()
Master James
  • 318
  • 5
  • 18