除了notepad.exe 可以正常启动隐藏外, 像 calc.exe 也无法隐藏!
查度娘: 说 程序本身的 nCmdShow 已经被赋值!
不知如何解决!求大佬们指点!
[Python] 纯文本查看 复制代码 # coding=utf-8
# python3.7.0
import subprocess
import threading
import time
import win32gui
CREATE_NO_WINDOW = 134217728
CREATE_NEW_CONSOLE = 16
# creationflags = 0
def pro(n):
pInfo = subprocess.STARTUPINFO()
# pInfo.dwFlags = subprocess.CREATE_NEW_CONSOLE
# https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa
pInfo.dwFlags = 0x000001
# pInfo.dwFlags = subprocess.STARTF_USESHOWWINDOW
# https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-showwindow
# pInfo.wShowWindow =
# p = subprocess.Popen(r'D:\GIN\py\tianqi\dist\tianqiGUI\tianqiGUI.exe', startupinfo=pInfo)
# p = subprocess.Popen(r'C:\Users\user\Desktop\日历.exe', startupinfo=pInfo)
p = subprocess.Popen(r'C:\Windows\notepad.exe', startupinfo=pInfo)
# p = subprocess.Popen(r'C:\Windows\System32\calc.exe', startupinfo=pInfo)
# p = subprocess.Popen('ping 127.1 -n 6', startupinfo=pInfo)
time.sleep(2)
print(p.pid)
p.kill()
if __name__ == '__main__':
pro(3)
|