我无法在单次执行中将目录从C:\
更改为C:\Apps\app.exe
。 Cmd不允许我这样做。我想先执行C:\Apps
,然后执行app.exe
参数以便使用app.exe
打开Process.Start()
并在一次运行中打开cmd.exe
。这是我的代码。
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...
答案 0 :(得分:0)
由于@Babbillumpa,我已经解决了我的问题:
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()