0
運行我的批處理文件時收到以下錯誤 「文件名,目錄名稱或卷標籤語法不正確」批處理文件問題,接收「文件名,目錄名稱或卷標籤語法不正確」
我的批處理文件運行良好,但是這個錯誤彈出了25次,然後繼續。我無法弄清楚我在這裏錯過了什麼。以下是我的代碼:
::This batch file is used to set a static IP and launch Windows Recovery Environment
@setlocal enableextensions enabledelayedexpansion
@echo off
::Setting Static IP Address & DNS Address
netsh interface ipv4 set address "Local Area Connection" static 10.11.111.110 255.255.255.0 10.11.111.249 1
netsh interface ipv4 set dns "Local Area Connection" static 10.11.101.1 primary
::Verify Network Connection
:chklink
set ipaddr=10.11.107.20
set oldstate=neither
set state=down
for /f "tokens=5,7" %%a in ('ping -n 1 !ipaddr!') do (
if "x%%a"=="xReceived" if "x%%b"=="x1," set state=up
)
if not !state!==!oldstate! (
echo.Link is !state!
set oldstate=!state!
)
REM ping -n 2 127.0.0.1 >nul: 2>nul:
SET answer=!state!
IF %answer%==up (
goto recovery
) ELSE (
IF %answer%==down (
::Set static address on NIC 2 if NIC 1 failed
netsh interface ipv4 set address "Local Area Connection 2" static 10.11.111.110 255.255.255.0 10.11.111.249 1
netsh interface ipv4 set dns "Local Area Connection 2" static 10.11.101.1 primary
goto chklink
)
)
::Launch Windows Recovery Environment
:recovery
cls
x:\sources\recovery\recenv.exe
exit
====================================== =====================
任何幫助將是偉大的!
謝謝!
德里克
試過了,它仍然拋出了一堆錯誤。 – 2011-02-17 14:50:07