Board logo

标题: 这个脚本运行不正常,哪点错了。 [打印本页]

作者: sevenwang2000     时间: 2008-5-12 14:27    标题: 这个脚本运行不正常,哪点错了。

@echo off

echo 当前网络配置如下:
ipconfig /all

echo 1.重新配置
echo 2.自动获取网络配置
echo 3.退出配置
set /p select=请选择任意一选项继续:

if select=="1" goto select1
if select=="2" goto select2
if select=="3" goto select3
               goto nothing

:select1
   set /p ip=请输入您的IP(格式为192.168.0.*):
   netsh interface ip set address name="本地连接" source=static address="%ip%" mask=255.255.255.0    gateway=192.168.0.254
   netsh interface ip set dns name="本地连接" source=static 218.2.135.1 primary
   goto end
:select2
   netsh interface ip set address name="本地连接" source=dhcp
   netsh interface ip set dns name="本地连接" source=dhcp
   goto end
:select3
   goto end
:nothing
   echo 你没有选择任何选项,程序将退出。
   goto end

:end
pause

[ Last edited by sevenwang2000 on 2008-5-12 at 02:29 PM ]
作者: plp626     时间: 2008-5-12 14:41
select=="1"
改为
“%select%”=="1"
试试
作者: tvzml     时间: 2008-5-12 15:59
@echo off

echo 当前网络配置如下:
ipconfig /all

echo 1.重新配置
echo 2.自动获取网络配置
echo 3.退出配置
set /p select=请选择任意一选项继续:

if %select%==1 goto select1
if %select%==2 goto select2
if %select%==3 goto select3
goto nothing

:select1
   set /p ip=请输入您的IP(格式为192.168.0.*):
   netsh interface ip set address name="本地连接" source=static address="%ip%" mask=255.255.255.0    gateway=192.168.0.254
   netsh interface ip set dns name="本地连接" source=static 218.2.135.1 primary
   goto end
:select2
   netsh interface ip set address name="本地连接" source=dhcp
   netsh interface ip set dns name="本地连接" source=dhcp
   goto end
:select3
   goto end
:nothing
   echo 你没有选择任何选项,程序将退出。
   goto end

:end
pause
作者: sevenwang2000     时间: 2008-5-12 18:51
已经解决,IP和网关要分别设置

[ Last edited by sevenwang2000 on 2008-5-12 at 09:36 PM ]