Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > starting programs from python script on windows

Reply
Thread Tools

starting programs from python script on windows

 
 
Benedict Verheyen
Guest
Posts: n/a
 
      01-28-2008
Hi,


i want to automate starting programs on my windows machine and i want
to do it with windows.
This is a sample script:

from subprocess import Popen, PIPE
import time

print " Starting app 1"
time.sleep(1)
try:
p1 = Popen(["C:\Program Files\Microsoft
Office\OFFICE11\OUTLOOK.EXE"], stdout=PIPE)
except Exception, e:
print "Error on startup app 1 %s " % str(e)

print " Starting app 2"
time.sleep(1)

try:
p2 = Popen(["C:\Windows\system32\cmd.exe"], stdout=PIPE)
except Exception, e:
print "Error on startup app 2 %s " % str(e)

It start it from a batch file:
SET PYTHONPATH=C:\Python25

rem - path to script to execute
%PYTHONPATH%\python.exe C:\login.py

This is the result:

C:\>C:\Python25\python.exe C:\login.py
Starting app 1
Starting app 2
Het proces heeft geprobeerd naar een niet-bestaande sluis te schrijven.
Het proces heeft geprobeerd naar een niet-bestaande sluis te schrijven.
Het proces heeft geprobeerd naar een niet-bestaande sluis te schrijven.

1. I get an error message saying the process has tried to write to a non
existing pipe.

2. Order of execution isn't respected: it prints the 2 messages and then
it tries to start the programs. Outlook is started but the command
prompt not.

Anyway, if it works, i would like to start using python to drive the
startup scripts of the users on the system.

How can i use python to start several programs as i would otherwise do
manually and keep the order i want?

Thanks,
Benedict

 
Reply With Quote
 
 
 
 
Piet van Oostrum
Guest
Posts: n/a
 
      01-30-2008
>>>>> Benedict Verheyen <(E-Mail Removed)> (BV) wrote:

>BV> Hi,
>BV> i want to automate starting programs on my windows machine and i want
>BV> to do it with windows.
>BV> This is a sample script:


>BV> from subprocess import Popen, PIPE
>BV> import time


>BV> print " Starting app 1"
>BV> time.sleep(1)
>BV> try:
>BV> p1 = Popen(["C:\Program Files\Microsoft Office\OFFICE11\OUTLOOK.EXE"],


Use raw strings or escape the \'s.
--
Piet van Oostrum <(E-Mail Removed)>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing string from python programs to external programs lone_eagle Python 3 05-26-2009 09:16 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C++ 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui C Programming 0 04-27-2009 12:51 PM
3 ESSENTIAL TOOLS FOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLSFOR STARTING AND MAINTAINING...3 ESSENTIAL TOOLS FOR STARTING ANDMAINTAINING... Oanh Bui Python 0 04-27-2009 12:46 PM
OS/2 C60 programs converted into MS windows programs?Information on OS/2 C60? Coca C Programming 7 08-24-2004 12:13 AM



Advertisments