E语言或批处理写一小程序
发布网友
发布时间:2022-05-09 18:08
我来回答
共2个回答
热心网友
时间:2023-10-11 23:02
代码如下:
@echo off
if "%1"=="h" goto begin
start mshta vbscript:createobject("wscript.shell").run("""%~nx0"" h",0)(window.close)&&exit
:begin
title ...
::============================================
set "file=D:\3\Debug\SFS_NICKNAME_Log.htm"
::需要监视的文件
set "close=x.exe"
::监视到那个文件被修改,需要关闭的程序
set "run=D:\3\Debug\1.exe"
::监视到那个文件被修改,需要启动的程序
::============================================
for /f "delims=" %%i in (%file%) do set "wd=%%i"
::
:loop
for /f "delims=" %%i in (%file%) do (
if not "%%i"=="%wd%" cls & goto change
)
cls & goto loop
:change
taskkill /f /im "%close%">nul
start "" "%run%">nul
cls & goto begin
热心网友
时间:2023-10-11 23:02
-------------------------------------------------------
@echo off&setlocal enabledelayedexpansion
copy /y Log.htm Log_1.htm >nul
echo.
echo.
echo.
echo.
echo. 监视文件中,请不要关掉窗口。最小化
echo.
echo.
echo.
echo.
echo.
echo.
:main
for /f "delims=*" %%a in ("Log.htm") do (
set t=%%~ta
set a=%%~aa
set z="%%~za"
)
for /f "delims=*" %%b in ("Log_1.htm") do (
set t1=%%~tb
set a1=%%~ab
set z1="%%~zb"
)
if not !a!==!a1! goto end
if not !z!==!z1! goto end
if not !t!==!t1! goto end
ping 127.1 -n 3 >nul
goto main
:end
taskkill /f /t /im x.exe >nul
start 1.exe >nul
exit
--------------------------------------------------------
代码存为BAT,放在D:\3\Debug下。
如不想要窗口,可加入计划任务中运行,新建任务。