批处理脚本时关闭 [英] Batch run script when closed

查看:106
本文介绍了批处理脚本时关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是我会怎样做一个批处理脚本而不是结束时,在右上角的X是pssed执行一个名为exit.exe文件$ P $。

My question is how would I make a batch script instead of closing when the X in the top right is pressed to execute a file called exit.exe.

推荐答案

在[X]为遥不可及的 CMD 。只有这样,我能想到的是:创建另一个 CMD 来观看当前窗口的presence:

the [X] is "out of reach" for cmd. Only way, I can think of is: create another cmd to watch the presence of the current window:

@echo off
title WatchMe
more +7 %~f0 >t2.bat
start "watcher" t2.bat

exit /b

@echo off
:running
tasklist /v|find "WatchMe" >nul &&echo waiting || goto finished
timeout 1 >nul
goto running
:finished
echo "the process has finished

这篇关于批处理脚本时关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆