Python win32process.STARTF_USESTDHANDLES Examples
The following are 1
code examples of win32process.STARTF_USESTDHANDLES().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32process
, or try the search function
.
Example #1
Source File: winpty.py From marsnake with GNU General Public License v3.0 | 6 votes |
def start(self, cmd): sAttr = win32security.SECURITY_ATTRIBUTES() sAttr.bInheritHandle = True stdout_r, stdout_w = win32pipe.CreatePipe(sAttr,0) stdin_r, stdin_w = win32pipe.CreatePipe(sAttr,0) self.read_handle=stdout_r self.write_handle=stdout_w self.stdin_write=stdin_w si = win32process.STARTUPINFO() si.dwFlags = win32process.STARTF_USESHOWWINDOW | win32process.STARTF_USESTDHANDLES si.wShowWindow = win32con.SW_HIDE si.hStdInput = stdin_r # file descriptor of origin stdin si.hStdOutput = stdout_w si.hStdError = stdout_w hProcess, hThread, dwProcessID, dwThreadID = win32process.CreateProcess(None,"cmd", None, None, True, win32process.CREATE_NEW_CONSOLE, None, None, si) self.dwProcessID=dwProcessID self.hProcess=hProcess sleep(0.5) if self.hProcess == 0: DebugOutput("Start Process Fail:{:d}".format(win32api.GetLastError())) DebugOutput('[*] pid: {:x}'.format(self.dwProcessID)) self.Console_hwnd = get_hwnds_for_pid(self.dwProcessID) if len(self.Console_hwnd)==0: raise Exception("Fail to run,No Process!") DebugOutput('[*] hwnd:{:x}'.format(self.Console_hwnd[0]))