批处理,做一个每隔5秒钟就执行一条命令,怎么做?最好再把窗口隐藏掉1

2025-02-24 05:56:38
推荐回答(5个)
回答1:

你试试这个,写一个VBS,把msg * test替换成你要的命令。另外隐藏运行的批处理只能在任务管理器里面结束CMD.EXE才能结束。

dim fso,testfile
set fso = createobject("scripting.filesystemobject")
set testfile = fso.createtextfile(".\test.bat",true)
testfile.writeline(":s")
testfile.writeline("msg * test")
testfile.writeline("timeout 5")
testfile.writeline("goto s")
testfile.close
createobject("wscript.shell").run ".\test.bat",0

回答2:

先做一个你想要执行的BATCH文件,再做一个VBS然后用VBS调用BATCH可以隐藏执行
VBS代码如下
Dim wshshell
DO
Set Wshshell = CreateObject("Wscript.Shell")
Wshshell.run "cmd /c D:\test.bat",0,true
Set Wshshell = Nothing
Wscript.Sleep 5000
loop

回答3:

@echo off
start d:\a.exe 打开d:\a.exe
ping -n 10 127.0>nul 延时10N
start e:\b.exe 打开e:\b.exe
ping -n 100 127.0>nul 延时100N
taskkill /f /im "b.exe" 关闭b.exe

回答4:

shutdown -s -t 100
ping -n 5 127.1>nul
shutdown -a
ping -n 5 127.1>nul
echo 猪
pause

回答5:

@echo off
:hello
msg * "hello"
ping /n 5 127.1 >nul
goto hello