码迷,mamicode.com
首页 > Windows程序 > 详细

pyqt在windows下的cmd相关

时间:2018-09-17 11:38:27      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:test   kernel   star   read   signal   tmp   console   strip   out   

1. cmd调用

(1)

shell_cmd = ‘...‘
cmd = shlex.split(shell_cmd)
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while p.poll() is None:
line = p.stdout.readline()
line = line.strip()
if line:
s1 = str(line, encoding=‘utf-8‘) # encoding=‘gb2312‘
resture
+= s1

(2)模拟双击
CREATE_NO_WINDOW = 0x08000000
os.startfile("。。。.exe")

time.sleep(2)

subprocess.call(‘taskkill /F /IM 。。。.exe‘, creationflags=CREATE_NO_WINDOW)

 

 

2.打包后的cmd隐藏

几种方法组合食用效果更佳:

(1)

  import ctypes
    whnd = ctypes.windll.kernel32.GetConsoleWindow()
  if whnd != 0:
  ctypes.windll.user32.ShowWindow(whnd, 0)
  ctypes.windll.kernel32.CloseHandle(whnd)()

(2)

shell_cmd = ‘...‘
cmd = shlex.split(shell_cmd)
p = subprocess.Popen(cmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while p.poll() is None:
line = p.stdout.readline()
line = line.strip()
if line:
s1 = str(line, encoding=‘utf-8‘) # encoding=‘gb2312‘
resture += s1

(3)
CREATE_NO_WINDOW = 0x08000000
subprocess.call(‘taskkill /F /IM test8_btc.exe‘, creationflags=CREATE_NO_WINDOW)
 

 (4) spec文件

exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name=‘test_addr‘,
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=False ) # console置为False



pyqt在windows下的cmd相关

标签:test   kernel   star   read   signal   tmp   console   strip   out   

原文地址:https://www.cnblogs.com/moon-fire/p/9660748.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!