Sneh Shah Sneh Shah - 12 days ago 4x
Python Question

How to make a Python script run a powershell script after it executes

I have two scripts one is Python based and other is powershell based.
My requirement is that I need to first run the Python script and then the powershell script on startup.

Using Task Scheduler I can run the Python script but I need to find a way to run powershell script after the python script finishes.

Some research online shows that I can add something like:

os.system ("powershell.exe script.ps1") in my Python script
but that is throwing an error: (unicode error) 'unicodeescape' codec can't decode bytes in position.....

Any suggestions?


Instead of calling the Powershell script from inside the Python script, you should run both the scripts using the task scheduler itself.

Assuming that the command you gave to the scheduler was something like python, you should change it to cmd_script.cmd where the contents of the cmd_script.cmd would be python & powershell.exe script.ps1