Re: launch a .py file from a batch file



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.

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.



.



Relevant Pages

  • Launching a JAVAW application
    ... I am using a batch file to launch a javaw app. ... windows registry. ...
    (comp.lang.java.programmer)
  • Re: Autolaunch a .bat file
    ... The main purpose of my batch file is to update that particular app. ... put my batch file in the startup directory... ... I'm not sure that CE is able to launch .bat ...
    (microsoft.public.windowsce.platbuilder)
  • launch a .py file from a batch file
    ... I'd like to launch a number of programs, one of which is a Python GUI ... have it open all the stuff and then not show the "DOS" console. ... The others open fine and no Python app. ...
    (comp.lang.python)
  • Re: Installing over an existing application.
    ... Vince wrote: ... What I did was to create a batch file which: ... >>sure the app is shut down completely before proceding (you can launch ... >>that batch file with Shell and immediately shut the app down) or... ...
    (microsoft.public.vb.enterprise)
  • Spawning a new UI process
    ... I'm working on a wxPython app that presents the user with a selection of several wxPython apps that exist on their system. ... They choose one, and I want to then "launch" that app, as if they had typed "python myapp.py" from a terminal window. ...
    (comp.lang.python)