launch a .py file from a batch file

Dave Angel davea at ieee.org
Tue Jun 23 09:21:01 EDT 2009


Paul Moore wrote:
> 2009/6/23 C M <cmpython at gmail.com>:
>   
>>> Assuming you're running on Windows XP, try the following line in your
>>> batch file:
>>> @start path\MyPythonApp.pyw
>>>
>>> That's of course after you rename your script to a pyw extension.  That's
>>> associated with pythonw, which doesn't need a command window.
>>>       
>> Well, I renamed my script to have a .pyw extension, and then ran the line
>> above.  Without quotes, it doesn't find it (because I have spaces in the
>> path).
>> With quotes it just opens a console and does nothing (does not launch the
>> app).
>>
>> Any ideas?
>>     
>
> Use
>
> @start "" "path\MyPythonApp.pyw"
>
> The first item in quotes is the window title. If you only include the
> path (in quotes) it's taken as a title, which is why you need the
> second set of quotes.
>
> Paul.
>
>   
CM - Paul is right.  If you have to use quotes, then you also need the 
extra argument to hold the "title" for the command window that won't be 
created.  Stupid syntax on "Start.exe".  I seldom hit that because I try 
not to put anything in a directory with spaces in it, like   "Program 
Files" or "Documents and Settings"

I have uncovered dozens of bugs in other people's programs over the 
years that were triggered by spaces in the pathname.  It's not so bad 
now, but still can bite you.





More information about the Python-list mailing list