0

I'm trying to launch a program using powershell that is located in c:\program files

PS C:\mydir> "c:\program files\node18\npm" run test
At line:1 char:31
+ "c:\program files\node18\npm" run test
+                               ~~~
Unexpected token 'run' in expression or statement.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnexpectedToken

When I try enclosing the entire command with quotation marks, he simply echoes the command back:

PS C:\mydir> "c:\program files\node18\npm run test"
c:\program files\node18\npm run test

Finally the solution suggested in Spaces cause split in path with PowerShell is not working for me:

PS c:mypath> & "c:\program files\node18\npm run test"

& : The term 'c:\program files\node18\npm run test' is not recognized as the name of a cmdlet, function, script file,
le program. Check the spelling of the name, or if a path was included, verify that the path is correct and
.
 char:3
rogram files\node18\npm run test"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
egoryInfo          : ObjectNotFound: (c:\program files\node18\npm run test:String) [], CommandNotFoundExcepti

lyQualifiedErrorId : CommandNotFoundException
Ya.
  • 1,671
  • 4
  • 27
  • 53
  • 2
    `& "c:\program files\node18\npm run test"` – Abdul Niyas P M Mar 20 '23 at 13:44
  • 1
    @AbdulNiyasPM - Add an explanation of what's happening and why the querent needs the `&`, and propose it as an answer instead of a mere comment. – Jeff Zeitlin Mar 20 '23 at 13:50
  • Not working. & "c:\program files\node18\npm run test" & : The term 'c:\program files\node18\npm run test' is not recognized as the name of a cmdlet, function, script file.... – Ya. Mar 20 '23 at 14:17

0 Answers0