批处理修改IP--netsh的用法

来源:互联网 发布:monkey源码 编辑:程序博客网 时间:2024/05/08 10:04

使用批处理修改IP

要使用批处理IP首先要使netsh能在dos执行,不能执行则有以下两种方法解决

替换 Framedyn.dll 文件
1. 单击开始,然后单击运行。
2. 在打开框中,键入 %systemroot%/system32/dllcache,然后单击确定。
3. 右键单击 framedyn.dll,然后在显示的快捷菜单上单击复制。
4. 单击开始,然后单击运行。
5. 在打开框中,键入 %systemroot%/system32/wbem,然后单击确定。
6. 在编辑菜单中,单击粘贴。如果提示是否替换现有文件,请单击是。

验证系统变量
1. 单击开始,右键单击我的电脑,然后在出现的快捷菜单上单击属性。如果收到以下错误信息,请单击确定:
rundll32.exe - Unable To Locate Component
This application has failed to start because framedyn.dll was not found.Re-installing the application may fix this problem.
2. 在系统属性对话框中,单击高级选项卡。
3. 单击环境变量。
4. 在“系统变量”中,单击路径,然后单击编辑。
注意:如果没有列出路径变量,则请单击新建。在“变量名”框中键入路径。
5. 在“变量值”框中键入:
%SystemRoot%/system32;%SystemRoot%;%SystemRoot%/System32/wbem
6. 单击确定三次(每当出现“确定”选项时)。

netsh命令能使用了  复制以下代码,存在.bat文件里就可以使用了

@ echo off
rem #--------------
rem #接口IP配置
rem #--------------

echo "ip configure script:"
echo "选择"d"键,进行自动获取IP地址及DNS配置"
echo "选择"h"键,进行宿舍"
echo "选择按键进行配置IP"
set /p ch=

if %ch% == echo "you input null" &goto:EOF
set case=d,h,w>nul
echo %case%|findstr "/<%ch%/>"> nul & if errorlevel 1 goto :err
goto %ch%
goto err

:h
::"宿舍配置"
echo "宿舍 address,please wait 30 second ..."
@netsh interface ip set address "本地连接" static 192.168.121.111 255.255.255.0 192.168.121.22 gwmetric=1>nul
@netsh interface ip set dns "本地连接" static 192.168.121.22 primary>nul
echo home ip configure is done
goto:EOF

:d
::DHCP "dhcp自动获取ip地址"
echo "configure stransport ip address geteway,please wait 30 second..."
@netsh interface ip set address "本地连接" dhcp>nul
@netsh interface ip set dns "本地连接" dhcp>nul
echo stransport ip configure is done
goto:EOF

:err
:: "error "
echo you input "%ch%",no this arguement! please intput h or w!game over
rem #接口IP配置结

rem #------  完  --------

IP地址可以根据自己修改

原创粉丝点击