@echo off
set /p option=(1) Edit IP (2) Enable DHCP:
if %option%==1 (
set /p IP=New IP-Address:
set /p MASK=New Network Mask:
set /p GATE=New Gateway Address:
netsh interface ip set address name="LAN" static %IP% %MASK% %GATE% 1
)
if %option%==2 (
netsh interface ip set address name="LAN" source=dhcp
)
pause
The DHCP part of the program works just fine. The NIC's name is "LAN". I have tried with and without the 1 paramenter on the set IP. I have also tried with different variable names.
The error I get after entering a valid ipv4 address, a subnetmask and a gateway address is:
Invalid Address Parameter <1>: Must be a valid IPv4-Address
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…