Tommy He
Tommy He

Reputation: 25

Powershell script cannot recognize absolute file path

I have a windows command script that needs to run another powershell script in another location. The windows command script contains the following code:

powershell -NoProfile -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; & "C:\Users\Tommy\AppData\bootstrap\bootstrap.ps1" -Update"

When I run the windows command script, it always show the following error:

& : The term 'C:\Users\Tommy' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At line:1 char:53

I have tried adding dot to the front of the absolute file path and it did not work.

Upvotes: 1

Views: 1172

Answers (1)

ekeeling
ekeeling

Reputation: 371

Try updating "C:\Users\Tommy\AppData\bootstrap\bootstrap.ps1" to 'C:\Users\Tommy\AppData\bootstrap\bootstrap.ps1'. You are ending your quotes early by using the double quotes again.

powershell -NoProfile -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; & 'C:\Users\Tommy\AppData\bootstrap\bootstrap.ps1' -Update"

Upvotes: 1

Related Questions