在我的工作中,我们使用批处理文件在晚上重启服务。但是有一些问题。 1是批处理运行时,在命令提示符下出现错误消息:ERROR: The process "nameofservice.exe" not found.
几次,然后关闭并完成。这不是一个太大的问题,但我注意到在某些情况下,错误信息会不断显示,而且永远不会关闭。
我遇到的另一个问题是,我的知识最近才开始发生,是批处理脚本不断运行。它应该通过并重新启动所有列出的服务一次,然后停止。但重新启动它们之后它又重新启动了。我必须在任务调度程序中将其设置为在6小时后终止(脚本应该花费20分钟)。
这是脚本:
@ECHO OFF
SETLOCAL EnableDelayedExpansion
ECHO ---------------------------------------------->> liblog.txt
ECHO -----------========================----------->> liblog.txt
ECHO -----------=========%date%=========----------->> liblog.txt
ECHO -----------========================----------->> liblog.txt
ECHO ---------------------------------------------->> liblog.txt
set DD=0
Set TIMESTAMP="eol=; tokens=1,2,3,4* delims=/, "
For /F %TIMESTAMP% %%i in ('DATE /t') DO (
SET YYYYMMDD=%%l%%j%%k
SET YYYYMM=%%l%%j
set DD=%%k
)
echo C2 >> libservers
echo G >> libservers
echo H >> libservers
echo I >> libservers
echo J >> libservers
echo K >> libservers
echo L >> libservers
echo M >> libservers
echo N >> libservers
echo O >> libservers
echo P >> libservers
echo Q >> libservers
echo R >> libservers
echo S >> libservers
echo T >> libservers
echo U >> libservers
echo V >> libservers
echo W >> libservers
echo X >> libservers
echo Y >> libservers
echo Z >> libservers
for /f %%a in (libservers) do (
set timestamp=!date!!time!
ECHO !timestamp! - Stopping Libserver %%a >> liblog.txt
net stop /y NuCPLibServerFB_%%a >> liblog.txt
taskkill /f /im NuCPLibServerFB_%%a.exe >> liblog.txt
ping localhost -n 30 > nul
if %DD%==01 (
ren D:\Libserver\Logs\LibServer_Server%%a.GDB LibServer_Server%%a_%yyyymm%.GDB >> liblog.txt
copy D:\Libserver\Logs\LibServer_Server.GDB D:\Libserver\Logs\LibServer_Server%%a.GDB
)
set timestamp=!date!!time!
ECHO !timestamp! - Starting Libserver %%a >> liblog.txt
net start NuCPLibServerFB_%%a >> liblog.txt
)
for /f %%a in (libservers) do (
set timestamp=!date!!time!
ECHO !timestamp! - Stopping Libserver %%a >> liblog.txt
net stop /y NuCPLibServerFB_%%a >> liblog.txt
taskkill /f /im NuCPLibServerFB_%%a.exe >> liblog.txt
ping localhost -n 30 > nul
set timestamp=!date!!time!
ECHO !timestamp! - Starting Libserver %%a >> liblog.txt
net start NuCPLibServerFB_%%a >> liblog.txt
)
if exist libservers del libserversrs
不幸的是,我不是那个写它的人,所以我不明白它是如何彻底运作的,我还在学习这些东西。
感谢任何帮助。我不是在寻找一个神奇的解决方案,只是帮助找出它为什么不起作用,任何建议都可以改善它。