From: Kevin B. <kb...@ca...> - 2002-02-11 15:52:57
|
Yang Wang wrote: > > Hi All, > > I am trying to use os.system("start mine.bat") to start a program in a > separate window. But the problem is that the control remains in the new > window and did not go back to the Jython window at all. Until I exit > the "mine.bat", the prompt in Jython began to show up. From "help start" on NT/4: > When executing an application that is a 32-bit GUI application, CMD.EXE > does not wait for the application to terminate before returning to > the command prompt. This new behavior does NOT occur if executing > within a command script. > Did I use the right command to do this? Yes. Maybe. system() starts a command and waits for it to complete. > I looked at other Python > commands such as os.execl() but when I try it on Jython, it would say > that "AttributeError: class 'org.python.modules.os' has no attribute > 'execl'". RSN I'll implement the os.exec() functions, but I haven't gotten around to it yet. Currently, to have your app continue running after launching the command, you can either: - run the command as java.lang.runtime.getRuntime().exec([ "cmd.exe", "/c", "mine.bat" ]) - run system in a separate thread as thread.start_new_thread( os.system, ("mine.bat",)) Note that either approach may leave your jython application without the focus (depends on what the MS Window Manager decides to do), so you may need to add a "setFocus" command to your jython GUI application. kb |