windows 系统 python 隐藏cmd 控制台窗口
使用bat文件
@echo off
if "%1" == "h" goto begin
mshta vbscript:createobject("wscript.shell").run("""%~0"" h",0)(window.close)&&exit
:begin
:: 关闭cmd控制台
lsrunase /user:Administrator /password:123456 /domain:test /command:"C:\Python37\pythonw.exe D:\xxx.py" /runpath:"%homepath%\desktop"
:: 管理员权限执行程序,防止代码内的权限不足
:: 使用 pythonw.exe D:\xxx.py python不会显示控制台窗口,相当于以后台运行的模式
浙公网安备 33010602011771号