1, ShellExecute function
import win32api
win32api.ShellExecute (0, ' Open ' , ' Notepad.exe ' , '' , '' , 0) # the background
win32api.ShellExecute (0, ' Open ' , ' Notepad.exe ' , '' , '' ,. 1 ) # front opening
win32api.ShellExecute (0, ' open ' , ' Notepad.exe ' , ' wmi.txt ' , '' , 1) # Open the file
win32api.ShellExecute (0, ' Open ' , ' iexplore.exe ' , ' https://www.baidu.com/ ' , '' ,. 1) # open Baidu IE browser URL
win32api.ShellExecute (0, ' Open ' , ' D: \ program Files (x86) \ QQ \ the Bin \ QQScLauncher.exe ' , ' ' , ' ' , 1) # open the QQ program
2、CreateProcess
The following Examples are opened, closed, determines whether or not closed
Import win32process Import Time # open Notepad, to obtain its handle handle win32process.CreateProcess = (R & lt ' C: \ the Windows \ Notepad.exe ' , '' , None, None, 0, win32process.CREATE_NO_WINDOW, None, None, win32process.STARTUPINFO ()) time.sleep(2) print(handle) # Terminate the process (program handles sentence, 0 off) win32process.TerminateProcess (handle [0], 0) Import win32event
# wait for the process to finish handle [0] to handle sentence window If -1, then waits. If the after closing sentence shank program output is 0 # may determine whether the program to close the Print (win32event.WaitForSingleObject (handle [0], -1))