<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><DIV>Hello,</DIV>
<DIV> </DIV>
<DIV>I am new in Python programming and I have the following problem:</DIV>
<DIV>I have a script in which I need to open an application (called from a batch file - "trace.bat"). For this purpuse, I'm executing the following piece of code:<BR> </DIV>
<DIV><FONT face="Courier New, courier, monaco, monospace, sans-serif">import os, win32process<BR>from win32api import Sleep<BR></FONT></DIV>
<DIV><FONT face="Courier New, courier, monaco, monospace, sans-serif">os.chdir("D:\\Marian\\Proiecte\\AMT\\Trace")<BR>os.startfile("launch_trace.bat")<BR>#subprocess.call("D:\\Marian\\Proiecte\\AMT\\Trace\\trace.bat")<BR>#pr = win32process.CreateProcess(None, "D:\\Marian\\Proiecte\\AMT\\Trace\\trace.bat", None, None, 0, win32process.NORMAL_PRIORITY_CLASS, None, None, win32process.STARTUPINFO())<BR></FONT></DIV>
<DIV><FONT face="Courier New">....</FONT></DIV>
<DIV><FONT face="Courier New">....</FONT></DIV>
<DIV><FONT face="Courier New">....</FONT></DIV>
<DIV><FONT face="Courier New">....</FONT></DIV>
<DIV> </DIV>
<DIV>But, when I call the "<FONT face="Courier New">os.startfile("launch_trace.bat")</FONT>" command, the program prompter appears, but the program called in the batch file is opened ONLY after the whole script has finished the execution.</DIV>
<DIV>Unfortunatley, after this line there are some very important things that has to be executed in the right order. I mean, the execution of the batch file is important for the rest of the code.</DIV>
<DIV>What is strange is that if I execute this code step-by-step, using the debugger, or if I put a breakpoint on the "launch_trace" line and then I step on it, everything is working fine - the Trace application is launced correctly.</DIV>
<DIV>Could anyone help in this direction? I need to launch the application and after this I want to continue the execution of the script.</DIV>
<DIV> </DIV>
<DIV>Thank you in advance!</DIV>
<DIV> </DIV>
<DIV>P.S. I've also tried with processes (see the commented lines) and I get the same problems; for MSWord application, the behavior is the same - it is launched after the script ends. Also, I have to mention that I don't have a DLL of this application and it is not a COM application in order to control it from Python.</DIV>
<DIV> </DIV>
<DIV>Marian</DIV></td></tr></table><br>