简体   繁体   中英

Batch script with correct escape characters

wmic nic where "netconnectionid like '%'" get netconnectionid

This code executes on the console properly but while i am trying to batch script like below script didn't execute. is there any suggestion? what is the correct escape charakters for below script?

Thanks.

@Echo Off
For /f "tokens=1*" %%a In ('wmic nic where "netconnectionid like '%'" get netconnectionid') Do (
    Call :UseNetworkAdapter "%%a %%b"
)

As user stated, he found the solution by putting in the extra %, which is required inside a batch script (as opposed to being run interactively from the command prompt). See corrected code below. I'm posting this as an answer since, like Chuck Kollars stated above, doing so will stop this from showing up in "unanswered" lists. Also, as an SO newbie, I feel like being a Point Pimp tonight. :)

@Echo Off
For /f "tokens=1*" %%a In ('wmic nic where "netconnectionid like '%%'" get netconnectionid') Do (
    Call :UseNetworkAdapter "%%a %%b"
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM