1

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.

1 Answer 1

1

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"
Sign up to request clarification or add additional context in comments.

1 Comment

Or use double quotes "" or a delimiter character `"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.