windows 保持后台运行

1.cmd 或 powersehll 执行 .exe文件,关闭 cmd 或 powershell 窗口后,运行的.exe进程会自动杀掉

  • 解决方法:先创建一个.bat文件:如 test.bat 内容如下
if "%1" == "h" goto begin 
mshta vbscript:createobject("wscript.shell").run("%~nx0 h",0)(window.close)&&exit 
:begin

(.exe 绝对路径, 如)C:\Users\admin\start.exe 

2. 运行

  • cmd 模式,进入 test.bat 目录,执行
test.bat
  • powershell 模式,进入 test.bat 目录,执行
./test.bat
posted @ 2021-09-09 20:07  tt_贝塔  阅读(843)  评论(0编辑  收藏  举报