winnt win32process.createProcess with stdout to file ?

david.humpherys at gmail.com david.humpherys at gmail.com
Thu Mar 3 21:14:34 EST 2005


Roger, I updated the script (below).. but now I get errors...
many thanks for your help.

import win32process, win32file, win32security, win32con, win32api,
thread, win32event, win32pipe

cmd = "c:/myexe.exe"
sa = win32security.SECURITY_ATTRIBUTES()
sa.bInheritHandle = 1

startInfo = win32process.STARTUPINFO()
startInfo.dwFlags = win32process.STARTF_USESTDHANDLES

fh = win32file.CreateFile("c:/mylog.log", win32file.GENERIC_WRITE,
win32file.FILE_SHARE_READ|win32file.FILE_SHARE_WRITE, sa,
win32file.OPEN_ALWAYS, win32file.FILE_FLAG_SEQUENTIAL_SCAN  , 0)
startInfo.hStdOutput = fh
startInfo.hStdError = win32api.GetStdHandle(win32api.STD_ERROR_HANDLE)
startInfo.hStdInput = win32api.GetStdHandle(win32api.STD_INPUT_HANDLE)

hProcess, hThread, dwProcessId, dwThreadId = win32process.CreateProcess
\
( None, cmd, sa, sa, 1, win32con.NORMAL_PRIORITY_CLASS, None, None,
startInfo)


ERROR:
pywintypes.error:(2, 'createProcess', ' the system cannot find the file
specified.;)

it's strange that it gets this error even though i have the
win32file.OPEN_ALWAYS flag set..

any suggestions... (soo... close!! )
thanks, thanks!
david




More information about the Python-list mailing list