ttnnaass 当前离线
一级士官
@ECHO off MODE CON COLS=100 LINES=1& COLOR 0A TITLE CHECK SERVER..... ECHO ***************** CHECK SERVER-1 SHARE FILES *********************** : SER1 IF EXTIST \\192.168.1.11\HHDD1 goto SER1-HHDD2 GOTO ERROR-SER1-HHDD1 : ERROR-SER1-HHDD1 ECHO %Date% >>SER1-HHDD1.txt ECHO %time% >>SER1-HHDD1.txt GOTO SER1-HHDD2 : SER1-HHDD2 IF EXTIST \\192.168.1.11\HHDD2 goto SER1-HHDD3 GOTO ERROR-SER1-HHDD2 : ERROR-SER1-HHDD2 ECHO %Date% >>SER2-HHDD2.txt ECHO %time% >>SER2-HHDD2.txt GOTO SER1-SERVER : SER1-HHDD3 IF EXTIST \\192.168.1.11\HHDD3 goto SER1-SERVER GOTO ERROR-SER1-HHDD3 : ERROR-SER1-HHDD3 ECHO %Date% >>HHDD3.txt ECHO %time% >>HHDD3.txt GOTO SER1-SERVER : SER1-SERVER IF EXTIST \\192.168.1.11\SERVER goto SER2 GOTO ERROR-SER1-SERVER : ERROR-SER1-SERVER ECHO %Date% >>SERVER.txt ECHO %time% >>SERVER.txt GOTO SER2 ECHO ***************** CHECK SERVER-2 SHARE FILES *********************** : SER2 IF EXTIST \\192.168.1.12\HHDD1 goto SER2-HHDD2 : ERROR-SER2-HHDD1 ECHO %Date% >>SER2-HHDD1.txt ECHO %time% >>SER2-HHDD1.txt GOTO ERROR-SER2-HHDD1 : ERROR-SER2-HHDD1 ECHO %Date% >>SER2-HHDD1.txt ECHO %time% >>SER2-HHDD1.txt GOTO SER2-HHDD2 : SER2-HHDD2 IF EXTIST \\192.168.1.12\HHDD2 goto SER2-HHDD3 GOTO ERROE-SER2-HHDD2 : ERROR-SER2-HHDD2 ECHO %Date% >>SER2-HHDD2.txt ECHO %time% >>SER2-HHDD2.txt GOTO SER2-HHDD3 : SER2-HHDD3 IF EXTIST \\192.168.1.12\HHDD3 goto SER2-SERVER GOTO ERROE-SER2-HHDD3 : ERROR-SER2-HHDD3 ECHO %Date% >>SER2-HHDD3.txt ECHO %time% >>SER2-HHDD3.txt GOTO ERROR-SER2-HHDD3 : SER2-SERVER IF EXTIST \\192.168.1.12\SERVER goto SER3 GOTO ERROE-SER2-SERVER : ERROR-SER2-SERVER ECHO %Date% >>SER2-SERVER.txt ECHO %time% >>SER2-SERVER.txt GOTO SER3 ECHO ***************** CHECK SERVER-3 SHARE FILES *********************** : SER3 IF EXTIST \\192.168.1.13\HHDD1 goto SER3-HHDD2 : ERROR-SER3-HHDD1 ECHO %Date% >>SER3-HHDD1.txt ECHO %time% >>SER3-HHDD1.txt GOTO ERROR-SER3-HHDD1 : ERROR-SER3-HHDD1 ECHO %Date% >>SER3-HHDD1.txt ECHO %time% >>SER3-HHDD1.txt GOTO SER3-HHDD2 : SER3-HHDD2 IF EXTIST \\192.168.1.13\HHDD2 goto SER3-HHDD3 GOTO ERROE-SER3-HHDD2 : ERROR-SER3-HHDD2 ECHO %Date% >>SER3-HHDD2.txt ECHO %time% >>SER3-HHDD2.txt GOTO SER3-HHDD3 : SER3-HHDD3 IF EXTIST \\192.168.1.13\HHDD3 goto SER3-SERVER GOTO ERROE-SER3-HHDD3 : ERROR-SER3-HHDD3 ECHO %Date% >>SER3-HHDD3.txt ECHO %time% >>SER3-HHDD3.txt GOTO SER3-SERVER : SER3-SERVER IF EXTIST \\192.168.1.12\SERVER goto REST GOTO ERROE-SER3-SERVER : ERROR-SER3-SERVER ECHO %Date% >>SER2-SERVER.txt ECHO %time% >>SER2-SERVER.txt GOTO REST ECHO ***************** REST 1 HOUR *********************** : RES ECHO.REST 1 HOUR PING 127.0.0.1 -N 3600>NUL 2>NUL GOTO SER1复制代码
find 当前离线
少将
TOP
ivor 当前离线
上校
你自己的测试结果表明是有问题还是没有问题? find 发表于 2012-2-26 11:15
最突出的问题是代码要精简一下 ivor 发表于 2012-2-26 11:33
CrLf 当前离线
论坛巡查
@echo off for %%a in (SER1-HHDD1 SER2-HHDD2 HHDD3) do ( echo %date% echo %time% )>>%%a.txt复制代码
粗看之下,似乎所有的 goto xxx 和标签都是多余的... 另外,如果要将一个时间写入不同文件,可以用 for 简 ... CrLf 发表于 2012-2-29 03:12