[python-win32] Newbie wmi + process running in background + stdio question

Larry Bates lbates at syscononline.com
Thu Oct 21 16:17:35 CEST 2004


Subject: [python-win32] Newbie wmi + process running in background +
	stdio	question
To: "'python-win32 at python.org'" <python-win32 at python.org>
Message-ID:
	<D24D16A6707B0A4B9EF084299CE99B3905EFD432 at mcl-its-exs02.mail.saic.com>
Content-Type: text/plain;	charset="iso-8859-1"


I am using TIm Golden's module to launch an application.  This brings up a
command console where the application then is writting status info to.  Is
it possible to instead have this output write to a file in the background?

Would appreciate any hints.

Take a look at using win32process.CreateProcess instead.  You have
control over creation of the window.  Below is some code I snipped
from a working application that may help.

        #
        # Didn't use os.system calls because it pops up DOS windows and I needed
        # to be able to control the APPpath environment under Win/98 & ME
        #
        STARTUPINFO=win32process.STARTUPINFO()
        STARTUPINFO.dwX=0
        STARTUPINFO.dwY=0
        STARTUPINFO.dwXSize=800
        STARTUPINFO.dwYSize=600
        commandLine=None
        processAttributes=None
        threadAttributes=None
        bInheritHandles=0
        dwCreationFlags=0
        if self.OSisNT:
            newEnvironment=None

        else:
            #
            # Windows/98 & ME don't handle APPpaths correctly, I must get the
Apppath
            # from the registry and pass to win32process.CreateProcess in the
newEnvironment
            # variable so search paths will be handled properly.
            #
            path, app=os.path.split(execute_target)
            #
            # Lookup APPpath for this application in the registry
            #
            #newEnvironment={'path':r'h:\public\orawin\042999\orawin\bin;f:\publ
ic\pb65\032200\deploy;h:\public\pixtran\081500\bin'}
            newEnvironment={'path': self.getAPPpath(app)}


        #
        # Start the program
        #
        win32process.CreateProcess(execute_target,
                                   commandLine,
                                   processAttributes,
                                   threadAttributes,
                                   bInheritHandles,
                                   dwCreationFlags,
                                   newEnvironment,
                                   currentDirectory,
                                   STARTUPINFO)




More information about the Python-win32 mailing list