- ·上一篇文章:批处理禁用除administrator之外所有用户(本机)
- ·下一篇文章:批处理文件简单加密
- ·百度中搜索更多的关于“网络配置备份恢复1.0(自动恢复)”相关内容
- ·谷歌中搜索更多的关于“网络配置备份恢复1.0(自动恢复)”相关内容
- ******申明******
- 本站文章内容有部分为收录网络中其他网友内容,DOS资源站不保证所有的代码都适合你使用。
- 由于编辑匆忙,有可能造成某些脚本文件出现丢失代码或代码无法运行的情况,请网友根据情况自行修改。
- 如果能将出错部分反馈给我,那就更好了。
网络配置备份恢复1.0(自动恢复)
参考了许多前辈的相关作品,拼凑成本批处理程序《网络配置备份恢复1.0》能够依据原来备份好的ipconfig信息,自动恢复原来的计算机名和网络设置信息。希望大家喜欢,给一些好的意见!
@echo off&title DOS资源站 www.cmdos.net
:: 代码编写:titiger
title 网络配置备份恢复1.0
::
if not exist ipconfig.txt echo 首次使用,正在生成备份网络信息……&&ipconfig/all >ipconfig.txt
:begin
::调用格式:
echo 正在读取备份网络信息……
call :select "Host Name" "name"
call :select "Physical Address" "mac"
call :select "ip address" "ip"
call :select "Subnet Mask" "mask"
call :select "Default Gateway" "gateway"
call :select "DNS Servers" "dns"
:loop
:: 显示备份信息
cls
echo 目前的备份网络信息:
echo.
echo 计算机名.....:%name%
echo mac地址......:%mac%
echo IP地址.......:%ip%
echo 子网掩码.....:%mask%
echo 网关.........:%gateway%
echo DNS地址......:%dns%
echo.
echo 1…查看当前网络信息,2…修改备份网络信息,3…执行备份网络设置恢复
echo 4…执行计算机名恢复,5…执行(备份网络设置+计算机名)恢复,Q…退出
set a=
set/p a=请选择:
if "%a%"=="1" cls&&echo 当前的网络信息:&&ipconfig/all&&pause
if "%a%"=="2" call ipconfig.txt&&goto begin
if "%a%"=="3" call :huifu2
if "%a%"=="4" call :huifu1
if "%a%"=="5" call :huifu2&call :huifu1
if "%a%"=="q" exit
goto loop
:huifu1
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %name% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f
echo 计算机名恢复成功(重新启动后生效):
set/p cx=任意键重新启动计算机(n.稍后再重新启动):
if not "%cx%"=="n" shutdown -r -t 0
goto :eof
:huifu2
netsh interface ip set address name="本地连接" source=static addr=%ip% mask=%mask%
netsh interface ip set address name="本地连接" gateway=%gateway% gwmetric=0
netsh interface ip set dns name="本地连接" source=static addr=%dns% register=PRIMARY
netsh interface ip set wins name="本地连接" source=static addr=none
echo 备份网络设置恢复成功:
ipconfig/all
pause
goto :eof
::**************************************************************
:: 解析ipconfig.txt内容输出通用函数
::**************************************************************
:select
for /f "tokens=2 delims=:" %%i in ('type ipconfig.txt ^| findstr /i /c:%1') do if not "!%~2!" == "" set "%~2=%%i"
goto :eof

