开发者

Batch File issue, recieving "The Filename, Directory Name, Or Volume Label Syntax Is Incorrect"

I'm recieving the following error when I run my batch file "The Filename, Directory Name, Or Volume Label Syntax Is Incorrect"

My batch file runs fine, but this error pops up 25 times and then proceeds. I can't f开发者_开发问答igure out what i'm missing here. Below is my code:

::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

===========================================================

Any help would be great!

Thanks!

Derek


Try taking out the :: comments and replacing them with rem ones. I've had difficulties in the past with using these inside control structures like if.

See here for an explanation. In fact that whole site is an incredible resource for cmd.exe scripters who, for some reason or another, aren't allowed to install CygWin.

Failing that, comment out the @echo off and see what it's doing when those errors appear.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜