473,507 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Howto Launch a windows application ?

hello,

I'm trying to launch a windows application,
but as many others on this list, I've some trouble.
I read some other threads about this topic,
but sorry, I still don't understand all this (never heard of pipes).

When I use a batch file, I can launch the bat-file from python,
and the windows application launched from the batchfile is run perfectly.

Now when I try to run the same windows application from Popen or call,
nothing happens (or at least it's very fast and produces not the
expected output).

Please enlighten me, preferable in "windows-terminology" ;-)

thanks,
Stef Mientki

from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

# DOESN'T WORK
result = call ( cmd )

# Both Popen and call work
cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
#output = Popen ( cmd )
result = call ( cmd )
print result

Oct 3 '07 #1
5 1992

stef mientki wrote:
hello,

I'm trying to launch a windows application,
but as many others on this list, I've some trouble.
I read some other threads about this topic,
but sorry, I still don't understand all this (never heard of pipes).

When I use a batch file, I can launch the bat-file from python,
and the windows application launched from the batchfile is run perfectly.

Now when I try to run the same windows application from Popen or call,
nothing happens (or at least it's very fast and produces not the
expected output).

Please enlighten me, preferable in "windows-terminology" ;-)

thanks,
Stef Mientki

from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

# DOESN'T WORK
result = call ( cmd )

# Both Popen and call work
cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
#output = Popen ( cmd )
result = call ( cmd )
print result
My guess is that with the redirect you simple need to set the 'shell'
option to true.

call(cmd, shell=True)

I haven't tested it, but it is worth a try.

Matt

Oct 3 '07 #2
stef mientki wrote:
cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append (
'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
Your problem is probably the last line there with the '>'. That's an
output redirection that is done not by jalv2_3.exe but by the command
shell. That's why it works only with the batch file (which is
interpreted by the command shell.

Using a batch file is probably easiest for this. But I'm guessing you
probably want to change the command line arguments passed to the program
that's why you prefer to build the command line manually.

In that case, there are a few solutions:
1) Generate the batch file programmatically.
2) Use cmd.exe /C (assuming you're on Windows XP). So your program would
be something like:
cmd.append('cmd.exe')
cmd.append('/C')
cmd.append('"D:\\PIC-tools\\JALxxx\\jalv2_3.exe -long-start -d -clear
-sD:\\PIC-tools\\JAL\\libs2
d:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l
>d:\\data_actueel\\d7_test_browser\\temp.log"')
(or something like that)
3) Do the redirection yourself. Remove the line:
cmd.append ('>d:\\data_actueel\\d7_test_browser\\temp.log' )
and instead read the results directly from the Popen.stdout. You can
then write the output to a file if you want.
Oct 3 '07 #3
Yu-Xi Lim wrote:
stef mientki wrote:
>cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append (
'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

Your problem is probably the last line there with the '>'. That's an
output redirection that is done not by jalv2_3.exe but by the command
shell. That's why it works only with the batch file (which is
interpreted by the command shell.

No that's not the problem,
leaving the redirection away,
gives the same problems.
Using a batch file is probably easiest for this.
I think indeed that's he simplest solution.
Still wonder why launching a windows program is "so difficult" in python
;-)

thanks,
Stef Mientki
But I'm guessing you
probably want to change the command line arguments passed to the program
that's why you prefer to build the command line manually.

In that case, there are a few solutions:
1) Generate the batch file programmatically.
2) Use cmd.exe /C (assuming you're on Windows XP). So your program would
be something like:
cmd.append('cmd.exe')
cmd.append('/C')
cmd.append('"D:\\PIC-tools\\JALxxx\\jalv2_3.exe -long-start -d -clear
-sD:\\PIC-tools\\JAL\\libs2
d:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l
>d:\\data_actueel\\d7_test_browser\\temp.log"')
(or something like that)
3) Do the redirection yourself. Remove the line:
cmd.append ('>d:\\data_actueel\\d7_test_browser\\temp.log' )
and instead read the results directly from the Popen.stdout. You can
then write the output to a file if you want.
Oct 4 '07 #4
Matimus wrote:
stef mientki wrote:
>hello,

I'm trying to launch a windows application,
but as many others on this list, I've some trouble.
I read some other threads about this topic,
but sorry, I still don't understand all this (never heard of pipes).

When I use a batch file, I can launch the bat-file from python,
and the windows application launched from the batchfile is run perfectly.

Now when I try to run the same windows application from Popen or call,
nothing happens (or at least it's very fast and produces not the
expected output).

Please enlighten me, preferable in "windows-terminology" ;-)

thanks,
Stef Mientki

from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )

# DOESN'T WORK
result = call ( cmd )

# Both Popen and call work
cmd = [ 'd:\\data_actueel\\d7_test_browser\\JALcc.bat' ]
#output = Popen ( cmd )
result = call ( cmd )
print result

My guess is that with the redirect you simple need to set the 'shell'
option to true.

call(cmd, shell=True)

I haven't tested it, but it is worth a try.

thanks, I tried, but it didn't work.

cheers,
Stef
Matt

Oct 4 '07 #5
On Oct 3, 5:39 pm, stef mientki <stef.mien...@gmail.comwrote:
>
from subprocess import *

cmd =[]
cmd.append ( 'D:\\PIC-tools\\JALxxx\\jalv2_3.exe' )
cmd.append ( '-long-start' )
cmd.append ( '-d')
cmd.append ( '-clear' )
cmd.append ( '-sD:\\PIC-tools\\JAL\\libs2' )
cmd.append ( 'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l' )
cmd.append ( '>d:\\data_actueel\\d7_test_browser\\temp.log' )
This is sort of aside from your original question, but I should also
point out how unnecessary all those 'cmd.append's are. You can
initialize the list all at once simply like so:

cmd =['D:\\PIC-tools\\JALxxx\\jalv2_3.exe',
'-long-start',
'-d',
'-clear',
'-sD:\\PIC-tools\\JAL\\libs2',
'd:\\pic-tools\\jal\\programs\\test_rs232\\test_rs232_hw.ja l',
'>d:\\data_actueel\\d7_test_browser\\temp.log']

Hyuga

Oct 8 '07 #6

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

Similar topics

7
30941
by: dan glenn | last post by:
I want to use some javascript to launch a windows application (this used on intranet) but don't know how. Can anyone help me out please? It'd be neat if I could not only launch the application...
1
5900
by: Michael Howes | last post by:
I have a c# windows form that talks to a web service on a server that then can talk to multiple "agents" on different machines using web service calls. I want to be able to launch an application...
7
2610
by: Paul | last post by:
Hi. I need to launch a windows application and then send keyboard event to this process to run certain commands. I've created a COM+ appplication to spawn and talk to the application which works...
7
287
by: arkam | last post by:
Well everything is in the title ! Arkam
8
3652
by: Paul | last post by:
I have looked and looked for this info. All the I/O examples I've found either explicity use a file name or use the OpenFileDialog. When you drag a MS Word document over MS Word, it launches and...
4
20821
by: Joe | last post by:
I created a CustomAction for this but I don't think I have it in the right place. I tried both Install and Commit but neither allow it to get to the final screen. Are there any examples of this...
5
20069
by: cooltoriz | last post by:
Hello there, I am not asking how to impersonate a process within C# windows application. I already know that, in C# v2.0, you can easily achieve it using ProcessStartInfo. You can run a process...
2
6074
by: JDeats | last post by:
When a user double clicks on file item in Windows Explorer, Windows tries to open the document with whatever application is related to it's file extension. In my WinForms application I would...
2
3975
by: dmitrey | last post by:
Hi all, here is a question already mentioned below, and I'm also interested in that one very much. unfortunatly, I can't write anything to matplotlib mailing lists because I constantly get server...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7111
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...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
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...
1
7031
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...
0
7485
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...
0
4702
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1542
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.