Scott Roland wrote: > I have a python script that can either be launched from cygwin, a DOS > cmd.exe shell, or by double clicking on the icon in a Windows Explorer > window. > > When it is launched by double clicking from a Windows Explorer window it > opens up a new cmd.exe window to run the program and the window closes > when it is done. I would like to be able pause at the end of execution > in this new window and wait for a key press, so that the user can see > what is in the window before it closes. I can check platform.system, and > make sure that I don't do this in cygwin, but how can I not make the > program pause for a key press when the script was launched from the > command line? > > At the moment I have created a shortcut that passes an argument to the > script, but I was hoping for a solution that doesn't involve editing the > shortcut.
The only hints I can see using to differentiate (and they aren't perfect) are: - When run from the shell os.environ will have changes that have been made to that shell's environment (if any). - When run from explorer, the path to the script (i.e. sys.argv[0]) will always be an absolute path. However, that isn't perfect because when run from the shell it *might* be an absolute path. When you run via explorer, what is actually being run is the "open" verb of your .py file association: C:\>assoc.py .py=Python.File C:\>ftype Python.File Python.File="C:\Python24\python.exe" "%1" %* If you only need this for your machine you could try to put some hint in the Python.File action. Trent -- Trent Mick [EMAIL PROTECTED] _______________________________________________ ActivePython mailing list ActivePython@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython