0

I saw this answer below, and had implemented something similar. However, whenever I start Notepad++ I receive an error that the file cannot be opened due to that file not existing. I will point out I am attempting to do this from the Root of C. Error:

Link to answer in question: Open file in chosen application in PowerShell

Error example pointing to the wrong file path

My little snippet is as follows:

$abcFilePath = "C:Test\abc-webservices\$ClientName\abc.xml"
$Openabc = Start-Process notepad++ "C:Test\abc-webservices\$ClientName\abc.xml" 

"TestCase" in the error is $ClientName from above. However based on the link I provided, should this not open up the correct file? Why is it attempting to navigate to the file from the folder Notepad++ is located in. Am I missing a step?

  • I have the path typed out in $Openabc because i was testing to see if it was my variable causing the problems. But when I call the variable in Powershell it does indeed list the file path I am expecting. – Tanner Martin Dec 05 '19 at 22:59
  • 2
    Can you try “C:\Test...” instead of “C:Test” in your paths? Without the backslash, the path is being calculated relative to the “current directory” on the C drive, which in your case is the folder that notepad++ is installed in. – mclayton Dec 06 '19 at 07:58
  • Thank you. That was it. This is why I like working with people. Catch my simple mistakes. I appreciate your assistance. – Tanner Martin Dec 06 '19 at 15:25

0 Answers0