2

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.

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

4

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

alapaah
  • 351
  • 2
  • 9
  • It doesn't work. I see the python.exe window pop up –  Jan 25 '21 at 08:57
  • 3
    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 – alapaah Jan 25 '21 at 09:04
  • Thank you it is working, after wasting days on this issue – Izik Apr 24 '23 at 14:56