How to tell Script to use pythonw.exe ?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Jul 3 03:29:52 CEST 2013


On Tue, 02 Jul 2013 18:20:12 -0700, goldtech wrote:

> Hi,
> 
> Using Windows....
> 
> I want to run a .py file script using pythonw.exe so the DOS box will
> not open. Is there a way from inside the script to say "run me with
> pythonw.exe and not python.exe"?

I don't believe so, because by the time the script is even opened, it is 
too late. I'm not an expert about Windows, but as I understand it, the 
process that occurs when you double-click the file is:

* Windows inspects the file extension and sees it is .py

* Windows checks the registry for the file extension association and 
finds python.exe

* Windows calls python.exe with the path to the script as argument

* finally python.exe opens the script.


Instead, you can use .pyw as the file extension, which should do what you 
want.



-- 
Steven



More information about the Python-list mailing list