欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Ghost安裝Win7/XP后自動恢復IP的批處理代碼(ip備份恢復)

 更新時間:2016年02月18日 16:42:36   投稿:mdxy-dxy  
這篇文章主要介紹了Ghost安裝Win7/XP后自動恢復IP的批處理代碼,其實就是在ghost系統(tǒng)之前將ip信息備份一下,等做完系統(tǒng)以后再恢復一下就可以了

今天維護人員找的我說,最近要推Win7了,暫時桌面云沒推廣,還是使用手動安裝Win7的方式。所以,需要我?guī)兔懸粋€腳本,大概功能就是在Ghost Win7之前先導出XP的IP信息,在Ghost完成之后,自動讀取這個IP信息用于恢復IP設置。
Ghost安裝Win7/XP后自動恢復IP的批處理

之前其實寫過一個XP的,這次是Win7的,其實大同小異了,花了近半小時測試成功了,現(xiàn)在來記錄一下。
懶得去折騰兼容方法,就寫了2個導出IP的腳本和一個IP恢復腳本,用于Ghost遠程安裝Win7后自動恢復IP設置的。(繁體環(huán)境)


1、導出WinXP系統(tǒng)IP信息:

@echo off&setlocal enabledelayedexpansion 
title WindowsXP IP信息導出工具(配合恢復腳本所用) 
echo IP信息導出中... 
for /f "tokens=1,2 delims=:" %%i in ('ipconfig') do ( 
 echo %%i | find /i "IP Address">nul && echo IP:%%j>D:\ip.txt 
 echo %%i | find /i "Subnet Mask">nul && echo MK:%%j>>D:\ip.txt 
 if "!GW!" equ "1" call :end 
 echo %%i | find /i "Default Gateway">nul && echo GW:%%j>>D:\ip.txt && set GW=1 
) 
 
:end 
echo= 
echo 導出完畢.任意鍵檢查... 
pause>nul 
start "" d:\ip.txt 
exit

2、導出Win7系統(tǒng)IP信息

@echo off&setlocal enabledelayedexpansion 
title Windows 7 IP信息導出工具(配合IP恢復腳本所用) 
echo IP信息導出中... 
for /f "tokens=1,2 delims=:" %%i in ('ipconfig') do ( 
 echo %%i | find /i "IPv4 位址">nul && echo IP:%%j>D:\ip.txt 
 echo %%i | find /i "子網(wǎng)路遮罩">nul && echo MK:%%j>>D:\ip.txt 
 if "!GW!" equ "1" call :end 
 echo %%i | find /i "預設閘道">nul && echo GW:%%j>>D:\ip.txt && set GW=1 
) 
 
:end 
echo= 
echo 導出完畢.任意鍵檢查... 
pause>nul 
start "" d:\ip.txt 
exit

Ps:測試過程中,發(fā)現(xiàn)win7 使用ipconfig命令,會有個IPv6的網(wǎng)關,導致出錯,只好用了一個 if 跳出循環(huán)。
3、最后輸出到D:\ip.txt的格式如下(太偷懶了,就三行,手動寫入也很快?。?/strong>

復制代碼 代碼如下:

IP: 10.197.198.173
MK: 255.255.255.254
GW: 10.197.198.1

最后,通過下面這個腳本讀取d:\IP.txt內(nèi)容并恢復IP:

@echo off&setlocal enabledelayedexpansion 
title Ghost系統(tǒng)后的IP恢復工具 
rem 判斷文件是否存在 
if not exist d:\ip.txt goto error 
 
rem 從IP.txt讀取信息,并設置變量 
for /f "tokens=1,2 delims=: " %%a in (d:\ip.txt) do ( 
 if /i "%%a"=="IP" set addr=%%b 
 if /i "%%a"=="MK" set mask=%%b 
 if /i "%%a"=="GW" set gateway=%%b 
) 
  
rem 獲取第一塊網(wǎng)卡的名稱,并設置IP,多塊網(wǎng)卡將至設置第一塊 
for /f tokens^=1^,2^ delims^=^" %%j in ('netsh interface ip show config') do (  
    
    if "%%j"=="介面 " ( 
     netsh interface ip set address name="%%k" source=static addr=!addr! mask=!mask! gateway=!gateway!  
     call :end      
       
      ) 
    if "%%j"=="接口 " ( 
     netsh interface ip set address name="%%k" source=static addr=!addr! mask=!mask! gateway=!gateway!  
     call :end      
   )   
  )  
 
:end 
echo 設置完畢,3S后自動退出! 
ping -n 3 127.1 >nul 
exit 
 
:error 
cls 
echo 錯誤:D盤根目錄未發(fā)現(xiàn)ip.txt文件!請手動設置IP,任意鍵退出... 
pause>nul 
exit

這個腳本簡、繁WinXP/7等系統(tǒng)都可以兼容設定IP,其實是修改自我以前寫的Windows下獲取網(wǎng)絡連線實際名稱,加強IP類設置腳本的兼容性中的腳本

4、腳本用法:

1、封裝Ghost系統(tǒng)鏡像時,將設置IP的腳本加入啟動項
2、Ghost安裝系統(tǒng)之前先通過【導出腳本】或【手動的方法】在d盤建立ip.txt,寫入如上三條信息
3、通過oneKey遠程恢復Ghost系統(tǒng)鏡像,等恢復完成之后,IP腳本自動恢復D盤設定好的IP,這時就可以遠程連接電腦進行維護了,整個過程均不需要現(xiàn)場操作。

相關文章

最新評論