- @echo off&setlocal enabledelayedexpansion
- :fenpei
- set serverst=101
- set serverend=130
- set vdisk=e:\ttt
- set wdisk=e:\work
- cd /d e:\work
- for %%a in (*.txt) do (
- for /l %%b in (%serverst%,1,%serverend%) do (
- set servernum=win%%b
- echo servernum=!servernum!
- if not "!servernum!"=="false" (
- if not exist \\!servernum!\work\nook.txt (
- echo %date%%time%发现!servernum!空闲!分配任务!kkk:~0,-4!
- set !servernum!=false
- echo !servernum!
- copy %vdisk%\run\1.txt \\!servernum!\work\nook.txt >nul
- echo ERRORLEVEL=!errorlevel!
- if !errorlevel! equ 0 (copy %vdisk%\run\1.txt \\!servernum!\work\!kkk:~0,-4!.txt >nul) else (set !winservernum!=false&&echo %date%%time%服务器:!servernum!无法连接,放弃对此机发送指令!)
- del /q %wdisk%\server\ready\!kkk:~0,-4!.txt 2>nul
- timeout -t 10
- goto fenpei
- )
- )
- )
- )
- for /l %%a in (%serverst%,1,%serverend%) do (
- echo !win%%a!
- )
- pause
复制代码 这段代码的问题我自己觉得莫名其妙
首先,set !servernum!=false。但是echo !servernum!仍然是win101
其次,copy %vdisk%\run\1.txt \\!servernum!\work\nook.txt >nul肯定不能成功,但!errorlevel!值却是0
麻烦哪位大神能解释下原因。拜谢拜谢 |