473,584 Members | 2,874 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.p y"
import os
import webbrowser
import win32api

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

# path to application that is opened
path = "C:\\Progra m Files\\External Application.exe "

# get short name
shortpath = win32api.GetSho rtPathName(path )

# open external application
stdin, stdout, stderr = os.popen3(short path)
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.e xe" file.
If I run "shortcut.e xe" everything works fine but a black empty cmd
window opens and its kept open until I close the application
"ExternalApplic ation.exe".
How can I close that black empty window automatically?

Thanks in advance,
Nico
May 31 '06 #1
1 7423
> 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.p y"
import os
import webbrowser
import win32api

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

# path to application that is opened
path = "C:\\Progra m Files\\External Application.exe "

# get short name
shortpath = win32api.GetSho rtPathName(path )

# open external application
stdin, stdout, stderr = os.popen3(short path)
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.e xe" file.
If I run "shortcut.e xe" everything works fine but a black empty cmd window
opens and its kept open until I close the application
"ExternalApplic ation.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
May 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7576
by: Rajarshi Guha | last post by:
Hi, I have some code that runs an interactive program via popen3(). The program generates output which is then used later on. My script looks like this: o,i,e = os.popen3('/usr/local/adapt/bin/descmng -g') o.write('\n%s\n\n' % (redpick)) o.close() time.sleep(1)
1
3100
by: | last post by:
This could possibly be a bug, but I don't understand it fully so I'm posting here first. Searching the list told me other people are having this problem too. I have created a class which inherits popen2.Popen3. The problem is that popen2.Popen3 does not define a __del__ method to handle proper closing of the pipes or destruction of the...
13
4447
by: Russell E. Owen | last post by:
I'm trying to launch an application from Python 2.3 on Windows. The application is "ds9" (an image viewer), and is installed in C:\Program Files\ds9\ds9 On unix I just do: os.popen3("ds9") and close the returned files and all is good. (I'm not trying to communicate with the program via popen3 and so had been using os.spawnlp, but that...
1
1720
by: Kenneth Pronovici | last post by:
Hi, I have a problem with a popen2 pipe hanging partway through execution of a command. This happens in my function executeCommand() that is used for every "shell" command execution in my program. Source code for this function is below. My development environment is Debian unstable with Python 2.3.5. Within executeCommand(), output of...
2
1369
by: robert | last post by:
os.popen3 delivers no error exit status on .close() - while os.popen does Is this intended or a bug? How do I get the status? Robert Python 2.4.1 (#2, May 5 2005, 11:32:06) on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import os
0
1173
by: John | last post by:
Hello. Can anyone tell me how to get p.poll() or a workaound to work when using popen3() on windows? I use python 2.3. I am trying to launch a command window to execute a command and then check periodically to see if the command has finished executing. If it has not finished after a given amount of time, I want to close the process. Is...
2
2684
by: Pierre Rouleau | last post by:
Hi all, I have a consistent test case where os.popen3() hangs in Windows. The system hangs when retrieving the lines from the child process stdout. I know there were several reports related to os.popen3() hanging under Windows in this group before. I stumbled on a case where a piece of code works in some occasions and hangs consistently...
0
1601
by: Jonathan Mark | last post by:
hi all... I wrote a seemingly simple function (below) to use Popen3() and select() to run a program and capture its exit status, stdout output, and stderr output. It worked fine until the box was upgraded to Debian sarge. Now the call to select() always takes about 13 seconds before returning the first time. The delay only occurs when...
0
1661
by: Rocky Zhou | last post by:
python unzip At first, I tried to use 'os.popen3("unzip ...") like this: fin, fout, ferr = os.popen3("unzip -o -d %s %s" % (dest, zipfile)) strerr = ferr.read() # This makes the program hanging up if strerr: print >sys.stderr, strerr outlog.error(strerr)
0
7829
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7940
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8198
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5705
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5379
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3824
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3850
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1438
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.