Re: os.popen3() - how to close cmd window automatically?



Dear Python developers,

I use a short python script in order to run an external application plus to open a browser displaying a default page.

My Setup: Python 2.4.3. / Windows2000

# ----------------------------------------------------------------------
# Script "shortcut.py"
import os
import webbrowser
import win32api

# open default web browser and display webbpage
page = 'C:\\Temp\\Welcome.html'
webbrowser.open(page)

# path to application that is opened
path = "C:\\Program Files\\ExternalApplication.exe"

# get short name
shortpath = win32api.GetShortPathName(path)

# open external application
stdin, stdout, stderr = os.popen3(shortpath)
output = stdout.read()
errors = stderr.read()
stdin.close()
stdout.close()
stderr.close()
print output
print errors
# ----------------------------------------------------------------------


In order to make this Script available on other Windows2000 machines where no Python installation is present, I made this script executable using "py2exe" (http://www.py2exe.org/). This creates a "shortcut.exe" file.
If I run "shortcut.exe" everything works fine but a black empty cmd window opens and its kept open until I close the application "ExternalApplication.exe".
How can I close that black empty window automatically?

Thanks in advance,
Nico

replace console=[... by windows=[... in your setup.py

--
---
Rony Steelandt
BuCodi
rony dot steelandt (at) bucodi dot com

Visit the python blog at http://360.yahoo.com/bucodi


.



Relevant Pages

  • os.popen3() - how to close cmd window automatically?
    ... I use a short python script in order to run an external application plus to open a browser displaying a default page. ... If I run "shortcut.exe" everything works fine but a black empty cmd window opens and its kept open until I close the application "ExternalApplication.exe". ...
    (comp.lang.python)
  • Re: Launch an application and continue the scripts execution
    ... - the bat file is correct because if I manually open it ... the application is not opened unless the script is finished ... might be the easiest way) and then, within your Python script, wait until the new process is ready. ... e.g. wait until Microsoft Word opens: ...
    (comp.lang.python)
  • Re: Modifying a record field value while not blocking it to others
    ... And of course again the record you are trying to modify has not to be 'open' ... someone opens that ID=12 record everything in it is locked. ... often add a script line which opens a random record if the file holds enough ... system where customers use Credits when renting items and get Credits ...
    (comp.databases.filemaker)
  • Re: Right click on text vs. right click on hyperlink
    ... I were to do that the built-in Windows way, I have to go down about ... >> me to open in one step the editing page of any archive page in my ... >> contains the below Windows script. ... >> that url and opens the editing page. ...
    (microsoft.public.scripting.vbscript)
  • Re: perl to python
    ... sed and perl can let you do all that quick command line stuff. ... into a full blown script. ... scripts, call it from the python interpreter, whatever I need. ... If I stick to the traditional unix approach, ...
    (comp.lang.python)