我需要一个可以保持运行的批处理文件,如果" Unturned.exe"没有运行到start "" /b "C:\Users\Administrator\Desktop\1.lnk"
然后空闲并扫描并等待它再次关闭。喜欢在循环中。
这就是我现在使用的,但是这个和服务器之间没有通信,人们知道它即将重启。我现在只运行1台服务器。
@echo off
cls
color B
:loop
echo ===========================================================
echo ===========================================================
echo ======== UNTURNED SERVER RESTART SCRIPT By FATBOI =========
echo ===========================================================
echo ===========================================================
@timeout /T 1 /nobreak >NUL
echo ===========================================================
echo Killing all servers for restart...
echo ===========================================================
@timeout /T 1 /nobreak >NUL
taskkill /f /im Unturned.exe
echo ===========================================================
echo All servers have been killed
echo ===========================================================
echo ===========================================================
echo Servers starting...
echo ===========================================================
start "" /b "C:\Users\Administrator\Desktop\1.lnk"
@timeout /T 30 /nobreak >NUL
cls
echo ===========================================================
echo ===========================================================
echo ===== UNTURNED SERVER RESTART SCRIPT By JoeCooper2015 =====
echo ===========================================================
echo ==================Server Restart Time======================
echo ===========================================================
time /T
echo ===========================================================
echo ===========================================================
REM Every 4 hours kill and start servers. note 1H = 3600 seconds
REM use timeout then goto loop
@timeout /T 3600 /nobreak
goto loop
答案 0 :(得分:0)
:MyLabel
start "" /w Mygame.exe
Goto MyLabel
非常简单。
这是在VBS中的方法
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set objEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM Win32_ProcessStopTrace")
Do
Set objReceivedEvent = objEvents.NextEvent
msgbox objReceivedEvent.ProcessName
If lcase(objReceivedEvent.ProcessName) = lcase("Notepad.exe") then
Msgbox "Process exited with exit code " & objReceivedEvent.ExitStatus
WshShell.Run "c:\Windows\notepad.exe", 1, false
End If
Loop