J. Scott Elblein
Well-known member
I'm attempting to run a destination relative path from within a VB.NET app. I've made sure to use backslashes (rather than forward slashes), and also running the Process with the working directory set to the correct source path; still getting a The system cannot find the file specified error when trying to run it.
For example, I have (pseudo-code):
txtSource.text path = "C:\Windows\System32"
txtResult.text path = "..\notepad.exe"
Here's the Sub so far:
For example, I have (pseudo-code):
txtSource.text path = "C:\Windows\System32"
txtResult.text path = "..\notepad.exe"
Here's the Sub so far:
VB.NET:
Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
Try
' Create the process object
Dim pRun As New Process()
' Set it to run from the Source folder (Working Directory)
With pRun.StartInfo
.UseShellExecute = False
.WorkingDirectory = IO.Path.GetDirectoryName(txtSource.Text.Trim)
.FileName = txtResult.Text.Trim
End With
pRun.Start()
' Wait for it to finish
pRun.WaitForExit()
Catch ex As Exception
Debug.Print(ex.Message)
End Try
End Sub