Reputation: 23
I have written a script on Windows 7 which keeps giving me an error of "( was unexpected at this time." for the following code
if %vardns%=="NODNS" (
netsh interface ipv4 set address name="%__ethAdapter.42%" source=static addr=%varip_old% mask=%varsubnet_old% gateway=%vargateway_old% gwmetric=1
) else (
netsh interface ipv4 set address name="%__ethAdapter.42%" source=dhcp
)
I am not sure where the issue lies and have read many other posts. Any help would be kindly appreciated. Thanks in advance.
Upvotes: 2
Views: 1569
Reputation: 32930
You're getting this error because vardns
is probably empty, and the interpreter unrolls this line to:
if =="NODNS" (
Which is illegal syntax.
What you've been advised to do is correct -- add quotation marks around %vardns%
, like this:
if "%vardns%"=="NODNS" (
and it should work.
Upvotes: 3