0

I have this PowerShell script and I have manually executed this

powershell -Command "C:\shellcommand.ps1"

I am writing it as subprocess.check_output("powershell -Command 'C:\shellcommand.ps1'")

I am getting result as C:\\shellcommand.ps1\r\n. Actually I am trying to run a batch file from the script. Manually it is running.

Could you please help me how I can able to call this in python

2
  • Your title and your tags differ. Could you please clarify? Commented May 2, 2018 at 13:19
  • from my python script, I am trying to call a powershell script using command prompt commands Commented May 3, 2018 at 5:14

1 Answer 1

4

Parameter -Command is for cmdlets, and -File is for scripts.

Try This:

powershell -ExecutionPolicy ByPass -File"C:\shellcommand.ps1"

I think it will work for you.

Sign up to request clarification or add additional context in comments.

Comments

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.