Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide window when running a Task Scheduler task

I'm using Task Scheduler to execute python run.py. It works, but the Python interpreter pops up. I want to run run.py in the background without any interpreter popping up.

How can I do this? In Linux I'd just do python run.py & to get it to run in the background silently, but I'm not sure how to achieve the same in Windows with Task Scheduler.

like image 564
Jase Avatar asked Feb 13 '26 11:02

Jase


1 Answers

You can just change .py extension to .pyw and the python file will run in background.

And if you want to terminate or check if it actually running in background,

simply open Task manager and go to Processes you will see python32 running there.

EDIT

As you mentioned, this doesn't seem like working from command line because changing the file's .extension simply tells your system to open the file with pythonw application instead of python.

So when you are running this via command line as python .\run.pyw even with the .pyw this will run with python.exe instead of pythonw.exe.

Solution:

As you mentioned in the comments, run the file as pythonw .\run.pyw or .\run.py

or just double click the run.pyw file.

like image 120
Spiros Gkogkas Avatar answered Feb 16 '26 00:02

Spiros Gkogkas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!