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
txtSource.text path = "C:\Windows\System32"
txtResult.text path = "..\notepad.exe"
Private Sub btnTest_Click(sender As Object, e As EventArgs) Handles btnTest.Click
' Create the process object
Dim pRun As New Process()
' Set it to run from the Source folder (Working Directory)
.UseShellExecute = False
.WorkingDirectory = IO.Path.GetDirectoryName(txtSource.Text.Trim)
.FileName = txtResult.Text.Trim
' Wait for it to finish
Catch ex As Exception
IO.Path.GetDirectoryName("C:\Windows\System32") returns "C:\Windows"; the directory that contains "C:\Windows\System32".
StartInfo.Filename = "..\notepad.exe" tells the process to look for
notepad.exe in "C:\".
Also, for this to work, you need to set
StartInfo.UseShellExecute = True; see: ProcessStartInfo Class for the description.
With pRun.StartInfo .UseShellExecute = True .WorkingDirectory = txtSource.Text.Trim .FileName = txtResult.Text.Trim End With