标题: [系统相关] 请教下:WIN7下 怎样用批处理备份还原IP配置? [打印本页]
作者: luoyi001 时间: 2017-12-11 09:35 标题: 请教下:WIN7下 怎样用批处理备份还原IP配置?
请教下论坛大大,WIN7系统下 怎样用批处理备、还原IP配置?谢谢
作者: ivor 时间: 2017-12-12 08:30
本帖最后由 ivor 于 2017-12-12 09:04 编辑
回复 1# luoyi001
http://www.bathome.net/viewthrea ... D4%ADIP%C5%E4%D6%C3
获取成功后的地址会写到批处理后面,如果已经有IP信息则设置,不支持XP,win7 测试正常- @echo off
- for /f "skip=22 tokens=1,2 delims=:" %%a in ('type "%~f0"') do (
-
- if "%%a" equ "IP" set ip=%%b
- if "%%a" equ "MASK" set mask=%%b
- if "%%a" equ "DNS" set dns=%%b
- if "%%a" equ "GATE" set gate=%%b
- )
- IF DEFINED ip (
-
- netsh interface ip set address name="本地连接" source=static %ip% %mask% %gate% 1
- netsh interface ip set dns "本地连接" static %dns% primary
- echo IP地址设置成功
- ) else (
- echo get ip infomation
- echo.>>"%~f0"
- for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr "IPv4"') do echo IP:%%i>>"%~f0"
- for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr "子网"') do echo MASK:%%i>>"%~f0"
- for /f "tokens=2 delims=:" %%i in ('ipconfig /all ^| findstr "服务器"') do echo DNS:%%i>>"%~f0"
- for /f "tokens=2 delims=:" %%i in ('ipconfig ^| findstr "网关"') do echo GATE:%%i>>"%~f0" & goto :EOF
- )
- pause
- goto :EOF
- rem ============华丽的分割线==============
复制代码
作者: nsdbc 时间: 2021-9-8 08:54
回复 luoyi001
获取成功后的地址会写到批处理后面,如果已经有IP信息则设置,不支持XP,win7 测试 ...
ivor 发表于 2017-12-12 08:30
单机很好用……
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |