How to make an os.system call, without the pop up of the dos-box???

Willy Heineman william_p_heineman at pfizer.com
Fri Aug 4 14:21:23 EDT 2000


Sorry, I forgot that the second parameter to ShellExecute is a string
containing the verb of the action you want to do, usually "open".
Another way to go is to use win32process.CreateProcess. This starts the
command in a separate process and you have to do some special handling
if you want to wait until it completes:

        startupInfo = win32process.STARTUPINFO()
        hProcess, hThread, dwProcessId, dwThreadId = \
          win32process.CreateProcess(None, commandline, None,
                                     None, 0, 0, None, None,
                                     startupInfo)
        while (win32process.GetExitCodeProcess(hProcess) ==\
          win32con.STILL_ACTIVE):
            win32api.Sleep(50)

Mark's excellent documentation combined with Microsoft's will get you
where you want to go.



wheineman wrote:

> "Peter Arwanitis" <arwanitis at iabg.de> wrote:
> >Hi there,
> >
> >I try to call some system-calls under a windows-environment, but
> I'm not
> >able to make this in "invisible" mode...
> >
> >there are calls like:
> >os.system(r'rmdir /S /Q C:\arwa\dev\') #clear dir-structure
> recursive
> >
> >or
> >
> >os.system(r'copy ..\AccessDB_ORIG\OrigPTC.mdb
> >...\AccessDB_ORIG\PTC-000526.mdb')
> >
> >stuff like that :)
> >
> >any hints?
> >
> >thanks a lot
> >(=PA=)
> >
> >
> >
> >
> >
>
> Must be win32. You can always call win32api.ShellExecute if
> you've got Mark Hammond's pythonwin installed. The parameters are
> in order:
>   the handle of the parent window (can be None)
>   the filename of the executable as a string,
>   the parameters to be passed to the executable as a string,
>   the initial directory to run in as a string,
>   the show command
>
> Use win32con.SW_HIDE or 0 to run silent.
>
> -----------------------------------------------------------
>
> Got questions?  Get answers over the phone at Keen.com.
> Up to 100 minutes free!
> http://www.keen.com




More information about the Python-list mailing list