launch a .py file from a batch file

C M cmpython at gmail.com
Mon Jun 22 22:11:49 EDT 2009


On Mon, Jun 22, 2009 at 8:04 PM, Dave Angel <davea at ieee.org> wrote:

> CM wrote:
>
>> I'd like to launch a number of programs, one of which is a Python GUI
>> app, from a batch file launcher.  I'd like to click the .bat file and
>> have it open all the stuff and then not show the "DOS" console.
>>
>> I can launch an Excel and Word file fine using, e.g.:
>> Start "" "path/mydocument.doc"
>>
>> But if I try that with a Python file, like:
>> Start "" "path/myPythonApp.py"
>>
>> It does nothing.  The others open fine and no Python app.
>>
>> However, if I do this instead (where path = full pathname to Python
>> file),
>> cd path
>> myPythonApp.py
>>
>> it will launch the Python app fine, but it will show the "DOS"
>> console.
>>
>> How can I get it to launch a .py file and yet not show the console?
>>
>> Thanks,
>> Che
>>
>>
>>
> 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?

Thanks.
Che


>
> Your batch file itself will still display a cmd window while it's running,
> but it'll finish quickly.  This is the same as when using one to start a
> spreadsheet or whatever.
>
> If you cannot change the extension to the correct pyw extension, then try
> specifying the interpreter explicitly in the start line:
>
> @start  c:\python26\pythonw.exe   path\MyPythonApp.py
>
> You may need quotes in either of these cases, if you managed to include
> spaces in your pathnames.
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090622/d5bff02f/attachment-0001.html>


More information about the Python-list mailing list