【问题】
这里提到的,打包python中,由于python中调用windows的cmd去执行一些动作,所以打包后的python,结果还是会遇到,调用cmd窗口(执行了对应的命令后)一闪而过。
想要消除此cmd一闪而过的问题。
只希望运行命令,执行动作。彻底不希望看到cmd的窗口显示出来。
【解决过程】
1.网上搜了搜,是关于python调用cmd的一些内容,所以说了:
设置shell为false,类似于:
subprocess.call('cmd.exe', shell=False, ......)
3.或者:
给cmd.exe 添加/Q参数,类似于:
subprocess.call('cmd.exe /Q', shell=False, ......)
但是结果不行:
有朝这方向想过,上面的我试过不行
shell默认为False,为真的话,unix下相当于args前面添加了 "/bin/sh" "-c",window下,相当于添加"cmd.exe /c",和隐藏shell窗口没关系吧
2.也去看了看,cmd本身的一些参数支持:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\CLi>cmd /?
Starts a new instance of the Windows command interpreter
CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
[[/S] [/C | /K] string]
/C Carries out the command specified by string and then terminates
/K Carries out the command specified by string but remains
/S Modifies the treatment of string after /C or /K (see below)
/Q Turns echo off
/D Disable execution of AutoRun commands from registry (see below)
/A Causes the output of internal commands to a pipe or file to be ANSI
/U Causes the output of internal commands to a pipe or file to be
Unicode
/T:fg Sets the foreground/background colors (see COLOR /? for more info)
/E:ON Enable command extensions (see below)
/E:OFF Disable command extensions (see below)
/F:ON Enable file and directory name completion characters (see below)
/F:OFF Disable file and directory name completion characters (see below)
/V:ON Enable delayed environment variable expansion using ! as the
delimiter. For example, /V:ON would allow !var! to expand the
variable var at execution time. The var syntax expands variables
at input time, which is quite a different thing when inside of a FOR
loop.
/V:OFF Disable delayed environment expansion.