Search code examples
pythonpowershellcommand-promptwindows-task-schedulerrich

Run python.exe with Windows Terminal instead of Command Prompt


Recently I am playing around with Rich. It's really helpful while debugging and tracking code running progress. However, if I use task scheduler to auto-run python script, it will open command prompt to run the script instead of others like Window PowerShell. All the output from Rich will not show in command prompt. Is there anyway to set python.exe run by other instead of command prompt?

My batch file looks like this:

"C:\Python39\python.exe" "C:\PATH\TO\PyScript.py"

Using Rich in Windows Terminal PowerShell

In Command Prompt


Solution

  • Yes, there is a way to do this.

    Just use this command:

    powershell.exe "C:\Python39\python.exe C:\PATH\TO\PyScript.py"