title: Run a Relative Path in Windows?
body: <p>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 <code>The system cannot find the file specified</code> error when trying to run it.</p>
  
  <p><strong>For example, I have (pseudo-code):</strong></p>
  
  <p><code>txtSource.text path = "C:\Windows\System32"</code></p>
  
  <p><code>txtResult.text path = "..\notepad.exe"</code></p>
  
  <p><strong>Here's the Sub so far:</strong></p>
  
  <pre><code>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
  </code></pre>