Search code examples
pythoncmdscheduled-taskswindows-task-scheduler

Run Windows Task without cmd pop-up


I have a task launched by the task scheduler (python script). I don't want the cmd window appear (python.exe). I can't use SYSTEM user account or "Run whether user is logged on or not", is there any way to hide the cmd pop up ?

enter image description here

enter image description here

I can't use SYSTEM account because I have to retrieve the user name in my script and I have to choose "Run only when user is logged on" because the other is not allowed in my case.


Solution

  • Simply save it with a .pyw extension. This will prevent the console window from opening.

    EDIT:

    Documentation for it, found at the bottom of 2.2.2. Executable python scripts: https://docs.python.org/2.6/tutorial/interpreter.html#executable-python-scripts

    Edit 2, Updated answer (if it dosen't work with just .pyw):

    Right-click on the file and select properties. Then in "Opens with:" you press change, then you'll need to navigate to your python directory and choose "pythonw.exe". Then it should work just fine