接著1樓
if !OpChoice!==11 (
echo list disk>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
set /a CountDisk=0
set /a CountPart=0
set NumDisk=0
set bVldNum=n
set NumVol=0
set /a a=0
set /a CountWim=0
set /a NumWimSource=0
set /a NumDskG=0
set /a NumPart=0
set bBK=y
echo list disk>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt>%temp%\Out_DiskPart.txt
find /i "磁盤" %temp%\Out_DiskPart.txt>%temp%\Out_tmp.txt
for /f "skip=2 tokens=2 delims= " %%i in (%temp%\Out_tmp.txt) do (set /a CountDisk=%%i)
for /l %%i in (1,1,5) do (
if !bVldNum!==n (set /p NumDisk=請輸入要安裝或備份系統(tǒng)的目標磁盤編號,從0起編,默認第0塊磁盤----)
for /l %%j in (0,1,!CountDisk!) do (
if !NumDisk!==%%j set bVldNum=y
)
)
if !bVldNum!==n (echo 磁盤編號5次都輸錯,算了退出吧!&&exit)
::Ghost認為磁盤從1開始起編!
set /a NumDskG=!NumDisk!+1
set /p bBK=請問是進行備份嗎,如恢復輸入n,默認是備份y,直接回車----
echo select disk !NumDisk!>%temp%\DiskPart.txt
echo list part>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
::準備指定安裝或備份分區(qū)
set /p NumPart=你選擇在磁盤^<!NumDisk!^>上安裝或備份系統(tǒng),請輸入分區(qū)序號----
if !bBK!==y (
echo list vol>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
set bHvLabSr=n
for /l %%i in (1,1,5) do (
if !bHvLabSr!==n (
set /p LabelSr=請輸入系統(tǒng)備份gho文件的放置盤符,直接回車----
if not exist !LabelSr!: echo 你輸入的盤符是什么東西,根本不存在嗎?
if exist !LabelSr!: set bHvLabSr=y
)
)
if not exist !LabelSr!:\backup md !LabelSr!:\backup
set NameBack=bk_Mby
set /p NameBack=請輸入要備份文件名字,默認名字bk_Mby,直接回車----
%~dp0ghost -clone,mode=pdump,src=!NumDskG!:!NumPart!,dst=!LabelSr!:\backup\!NameBack!.gho /z9 /sure
goto End
)
if not !bBK!==y (
echo list vol>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
::指定要安裝分區(qū),請看卷標信息。
set bHvSYS=n
for /l %%i in (1,1,5) do (
if !bHvSYS!==n (
set /p LabSYS=請輸入要安裝系統(tǒng)分區(qū)盤符,就是那個序號對應的盤符,然后回車----
if not exist !LabSYS!: echo 你輸入的盤符是什么東西,根本不存在嗎?
if exist !LabSYS!: set bHvSYS=y
)
)
::指定EFI/MSR分區(qū)盤符,請看卷標信息。
set bHvSYS=n
for /l %%i in (1,1,5) do (
if !bHvSYS!==n (
set /p Label_ESP=請輸入EFI/MSR分區(qū)盤符,不帶冒號,然后回車----
if not exist !Label_ESP!: echo 你輸入的盤符是什么東西,根本不存在嗎?
if exist !Label_ESP!: set bHvSYS=y
)
)
set bNdCpyFil=n
set /p bNdCpyFil=請問需要從U盤復制gho文件嗎,如需要輸入y,默認不要n,直接回車----
if !bNdCpyFil!==y (
::現(xiàn)在準備把系統(tǒng)備份gho文件復制到本地卷中,請看卷標信息。
::指定系統(tǒng)備份gho文件文件本地磁盤放置分區(qū)。
set bHvLabSr=n
for /l %%i in (1,1,5) do (
if !bHvLabSr!==n (
set /p LabelSr=請輸入要放置系統(tǒng)備份gho文件的盤符,直接回車----
if not exist !LabelSr!: echo 你輸入的盤符是什么東西,根本不存在嗎?
if exist !LabelSr!: set bHvLabSr=y
)
)
if not exist !LabelSr!:\backup md !LabelSr!:\backup
::準備源系統(tǒng)備份gho文件與索引序號。
set bHvLSr=n
for /l %%i in (1,1,5) do (
if !bHvLSr!==n (
set /p LPartU=請輸入系統(tǒng)備份gho文件所在U盤盤符,不帶冒號----
if not exist !LPartU!: echo 這個盤符根本就沒有使用了,你不要搞笑好吧
if exist !LPartU!: set bHvLSr=y
)
)
dir !LPartU!:\*.gho /b /s >%temp%\fSeek.txt
echo 查找到!LPartU!分區(qū)下所有gho文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do ( set /a a+=1&&echo 系統(tǒng)備份:!a! %%i)
set /a CountWim=!a!
if !a!==0 echo 該分區(qū)無系統(tǒng)備份文件,退出重來吧!&&goto End
set /p NumWimSource=請輸入gho文件序號,我不檢測無效序號,不帶冒號----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效gho文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !NumWimSource!==!a! copy %%i !LabelSr!:\backup\
)
echo gho文件已拷貝到本地磁盤,程序暫停,U盤可以拔出它用,然后繼續(xù)。
pause
dir !LabelSr!:\*.gho /b /s >%temp%\fSeek.txt
echo 查找到!LabelSr!分區(qū)下所有gho文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do ( set /a a+=1&&echo 系統(tǒng)gho:!a! %%i)
set /a CountWim=!a!
set /p NumWimSource=請輸入系統(tǒng)gho文件序號,我不檢測無效序號,不帶冒號----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效系統(tǒng)gho文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !NumWimSource!==!a! ( %~dp0ghost -clone,mode=pload,src=%%i:1,dst=!NumDskG!:!NumPart! /sure )
)
)
if not !bNdCpyFil!==y (
set bHvLabSr=n
for /l %%i in (1,1,5) do (
if !bHvLabSr!==n (
set /p LabelSr=請輸入有系統(tǒng)備份gho文件的盤符,直接回車----
if not exist !LabelSr!: echo 你輸入的盤符是什么東西,根本不存在嗎?
if exist !LabelSr!: set bHvLabSr=y
)
)
dir !LabelSr!:\*.gho /b /s >%temp%\fSeek.txt
echo 查找到!LabelSr!分區(qū)下所有gho文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do ( set /a a+=1&&echo 系統(tǒng)gho:!a! %%i)
set /a CountWim=!a!
set /p NumWimSource=請輸入系統(tǒng)gho文件序號,我不檢測無效序號,不帶冒號----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效系統(tǒng)gho文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !NumWimSource!==!a! ( %~dp0ghost -clone,mode=pload,src=%%i:1,dst=!NumDskG!:!NumPart! /sure )
)
)
if !bPart_GPT!==y %windir%\system32\bcdboot !LabSYS!:\windows /s !Label_ESP!: /f uefi /l zh-cn
if not !bPart_GPT!==y (
if exist !LabSYS!:\ntldr %windir%\system32\bootsect.exe /nt52 !Label_ESP!: /force /mbr
if not exist !LabSYS!:\ntldr %windir%\system32\bootsect.exe /nt60 !Label_ESP!: /force /mbr&&%windir%\system32\bcdboot !Label_SYS!:\windows /s !Label_ESP!: /f bios /l zh-cn
)
)
goto End
)
if !OpChoice!==12 (
set bVldNum=n
set NumVol=0
set /a a=0
set NumSdi=1
set /a CountWim=0
set NumWimSource=1
set bHvFilePE=n
echo ------------------------------------------------------------------------------
echo.
echo 將PE安裝在EFI分區(qū)或者MSR分區(qū)內(nèi),防止PE受損,沒有這種分區(qū)你就老外了。
echo.
echo ------------------------------------------------------------------------------
echo PE放于指定盤根目錄下WinPE文件夾,設備文件Boot.sdi和啟動文件Boot.wim也固定。
set bIsUEFI=y
set /p bIsUEFI=請問BIOS是否UEFI,默認是,不是請輸入小寫n----
set bHvLab=n
set /p bHvLab=采用MBR但無MSR,或者MBR中MSR分區(qū)/ESP分區(qū)如已有盤符,輸入y,其余直接回車----
if !bHvLab!==y (
set /p LabelEFI=請輸入ESP分區(qū)或MBR中MSR分區(qū)盤符或者MBR無MSR分區(qū)時的系統(tǒng)盤符----
)
if not !bHvLab!==y (
::給EFI或者MSR分區(qū)分配盤符
set bHvSetESP=n
for %%i in (z y x w v u t s r q p o n m) do (
if !bHvSetESP!==n ( if not exist %%i: set LabelEFI=%%i&&set bHvSetESP=y )
)
echo list vol>%temp%\DiskPart.txt
echo exit>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
set /p NumVolESP=請輸入GPT中ESP分區(qū)或MBR中MSR分區(qū)的卷編號,直接回車----
echo select vol !NumVolESP!>%temp%\DiskPart.txt
echo assign letter=!LabelEFI!>>%temp%\DiskPart.txt
echo exit>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
)
::UEFI引導需要PE源盤安裝硬盤PE,默認需要本PE源盤,MBR引導,默認也要
set bCopyPE=y
set /p bCopyPE=請問是否需要復制PE文件,默認需要,不需要輸入小寫n----
if not !bCopyPE!==n (
set name_PE=PE_MBY
set /p name_PE=默認安裝PE于!LabelEFI!:\PE_MBY目錄,也可輸入目錄名字,如PE_WYS----
if not exist !LabelEFI!:\!name_PE!\ md !LabelEFI!:\!name_PE!\
set name_PathSdi=!name_PE!
set name_PathWim=!name_PE!
set bHvLSr=n
for /l %%i in (1,1,5) do (
if !bHvLSr!==n (
set /p LPartU=請輸入PE源文件所在盤盤符,可以是本地硬盤,不帶冒號----
if not exist !LPartU!: echo 這個盤符根本就沒有使用了,你不要搞笑好吧
if exist !LPartU!: set bHvLSr=y
)
)
echo.
dir !LPartU!:\*.sdi /b /s >%temp%\fdSeek.txt
echo 查找到!LPartU!分區(qū)下所有映像引導文件*.sdi如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fdSeek.txt) do ( set /a a+=1&&echo 系統(tǒng)引導文件:!a! %%i)
set /a CountWim=!a!
if !a!==0 echo 該分區(qū)無PE系統(tǒng)映像引導文件,退出重來吧!&&goto End
echo -----------------------------------------------------
set /p NumSdi=請輸入系統(tǒng)映像引導文件序號,我不檢測無效序號,默認1----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumSdi!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效PE系統(tǒng)映像文件序號,退出重來吧!&&goto End
echo.
dir !LPartU!:\*.wim /b /s >%temp%\fwSeek.txt
echo 查找到!LPartU!分區(qū)下所有映像文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fwSeek.txt) do ( set /a a+=1&&echo PE系統(tǒng)映像:!a! %%i)
set /a CountWim=!a!
if !a!==0 echo 該分區(qū)無PE系統(tǒng)映像文件,退出重來吧!&&goto End
echo -----------------------------------------------------
set /p NumWimSource=請輸入PE系統(tǒng)映像文件序號,我不檢測無效序號,默認1----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效PE系統(tǒng)映像文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fdSeek.txt) do (
set /a a+=1
if !a!==!NumSdi! copy /y %%i !LabelEFI!:\!name_PE!\boot.sdi
)
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fwSeek.txt) do (
set /a a+=1
if !a!==!NumWimSource! copy /y %%i !LabelEFI!:\!name_PE!\boot.wim
)
)
if !bIsUEFI!==n (
set bCopyBoot=n
set /p bCopyBoot=是否需要從PE源盤復制MBR啟動環(huán)境文件,默認不,需要輸入小寫y----
if not !bCopyBoot!==n (
set bHvLSr=n
for /l %%i in (1,1,5) do (
if !bHvLSr!==n (
set /p LPartPE=請輸入PE源盤盤符,然后回車----
if not exist !LPartPE!: echo 這個盤符根本就沒有使用了,你不要搞笑好吧
if exist !LPartPE!: set bHvLSr=y
)
)
if not exist !LPartPE!:\boot\ ( echo 這個盤里沒有啟動環(huán)境文件,你不要搞笑好吧!&& goto End )
xcopy /h /y !LPartPE!:\bootmgr !LabelEFI!:\
if exist !LabelEFI!:\boot\ rd /s /q !LabelEFI!:\boot\
if not exist !LabelEFI!:\boot\ md !LabelEFI!:\boot\
robocopy !LPartPE!:\boot\ !LabelEFI!:\boot\ /e /xf bcd
)
)
set bbPE=y
set /p bbPE=請問是否建PE菜單項,默認建,如果不建輸入小寫n----
if not !bbPE!==n (
if !bCopyPE!==n (
::沒有復制源文件,說明ESP/MSR分區(qū)中已經(jīng)存在PE源文件,查找相應路徑
echo.
dir !LabelEFI!:\*.sdi /b /s >%temp%\fdSeek.txt
echo 查找到!LabelEFI!分區(qū)下所有映像引導文件*.sdi如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fdSeek.txt) do ( set /a a+=1&&echo 系統(tǒng)引導文件:!a! %%i )
set /a CountWim=!a!
if !a!==0 echo 該分區(qū)無PE系統(tǒng)映像引導文件,退出重來吧!&&goto End
echo -----------------------------------------------------
set /p NumSdi=請輸入系統(tǒng)映像引導文件序號,我不檢測無效序號,默認1----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumSdi!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效PE系統(tǒng)映像文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fdSeek.txt) do (
set /a a+=1
if !a!==!NumSdi! (
set namePathSdi=%%i
set name_PathSdi=!namePathSdi:~3,-9!
)
)
echo 引導文件路徑是:!name_PathSdi!
set /p name_PathSdi=如果路徑有誤,請手工輸入,默認不需要,直接回車----
echo.
dir !LabelEFI!:\*.wim /b /s >%temp%\fwSeek.txt
echo 查找到!LabelEFI!分區(qū)下所有PE映像文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fwSeek.txt) do ( set /a a+=1&&echo PE系統(tǒng)映像:!a! %%i)
set /a CountWim=!a!
if !a!==0 echo 該分區(qū)無PE系統(tǒng)映像文件,退出重來吧!&&goto End
echo -----------------------------------------------------
set /p NumWimSource=請輸入PE系統(tǒng)映像文件序號,我不檢測無效序號,默認1----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效PE系統(tǒng)映像文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fwSeek.txt) do (
set /a a+=1
if !a!==!NumWimSource! (
set namePathWim=%%i
set name_PathWim=!namePathWim:~3,-9!
)
)
echo PE系統(tǒng)文件路徑是:!name_PathWim!
set /p name_PathWim=如果路徑有誤,請手工輸入,默認不需要,直接回車----
)
set name_MenuPE=PE_MBY
set /p name_MenuPE=輸入菜單項名字,默認PE_MBY,可自行輸入,如MAXDOS_WYS----
echo list vol>%temp%\DiskPart.txt
echo exit>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
set /p NumVolESP=請輸入GPT中ESP分區(qū)或MBR中MSR分區(qū)的卷編號,直接回車----
bcdedit /create {bootmgr} /d "Marc Boot Manager" >nul 2>nul
bcdedit /set {bootmgr} device partition=\device\harddiskvolume!NumVolESP! >nul 2>nul
::創(chuàng)建設備項
bcdedit /create /d "!name_MenuPE!" /device>%~dp0fdid.txt
::取得所生成的設備標識符
for /f "tokens=2 delims= " %%i in (%~dp0fdid.txt) do (set fdid=%%i)
::設置設備所在分區(qū)
bcdedit /set !fdid! ramdisksdidevice partition=!LabelEFI!:
::設置設備所在的固定路徑
bcdedit /set !fdid! ramdisksdipath \!name_PathSdi!\boot.sdi
::創(chuàng)建菜單項
bcdedit /create /d "!name_MenuPE!" /application osloader>%~dp0fmid.txt
::取得所生成的菜單標識符
for /f "tokens=2 delims= " %%i in (%~dp0fmid.txt) do (set fmid=%%i)
::設置啟動設備
bcdedit /set !fmid! device ramdisk=[!LabelEFI!:]\!name_PathWim!\boot.wim,!fdid!
::設置系統(tǒng)設備
bcdedit /set !fmid! osdevice ramdisk=[!LabelEFI!:]\!name_PathWim!\boot.wim,!fdid!
::設定啟動程序(winload)的路徑
if not !bIsUEFI!==n bcdedit /set !fmid! path \windows\system32\winload.efi
if !bIsUEFI!==n bcdedit /set !fmid! path \windows\system32\winload.exe
::設置系統(tǒng)根目錄
bcdedit /set !fmid! systemroot \windows
::開啟detecthal支持
bcdedit /set !fmid! detecthal yes
::開啟WinPE支持
bcdedit /set !fmid! winpe yes
::設置nx為optin
bcdedit /set !fmid! nx optin
::設置為最后一項顯示
bcdedit /displayorder !fmid! /addlast
bcdedit /timeout 2
bcdedit /enum
)
del /f /s /q %~dp0fdid.txt>nul 2>nul
del /f /s /q %~dp0fmid.txt>nul 2>nul
goto End
)
if !OpChoice!==13 (
echo.
echo 1:本批處理、驅(qū)動和補丁子目錄、IE升級包必需都在當前目錄。
echo 在同目錄中有\(zhòng)Driver、\patch和\IE固定目錄,放置驅(qū)動和補丁子目錄。
echo 如\Driver\Drv_Win8_x64,\patch\patch_Win8_x64
echo 調(diào)整Win7、Win8功能,可能還要準備Win8原版光盤,或者IE10安裝包。
echo.
echo 2:當前目錄下工作子目錄,掛載文件夾\Mount,臨時文件夾\tmp_Imgex。
echo 臨時文件*.txt都在系統(tǒng)臨時文件夾%temp%中。
echo.
pause
::準備全局變量
set /a a=0
set /a CountWim=0
set /a CountIndex=0
set /a NumWimSource=0
set /a IndexSource=0
::準備局部變量
set /a CountPatch=0
set /a NumPatch=0
set /a CountDrv=0
set /a NumDrv=0
set /a CountIE=0
set /a NumIE=0
cls
echo.
set bPatDism=y
set /p bPatDism=請問是否封裝系統(tǒng)補?。磕J是y,直接回車/不是輸入小寫n----
set bDrvDism=y
set /p bDrvDism=請問是否封裝硬件驅(qū)動?默認是y,直接回車/不是輸入小寫n----
set bIsWin8=y
set /p bIsWin8=請問是要操作Win8映像嗎?默認是y,直接回車/不是輸入小寫n----
if not !bIsWin8!==n (
set bEnabNet3=y
set /p bEnabNet3=請問是否啟用 .Net 3.5/2支持?默認是y,直接回車/不是輸入小寫n----
if not !bEnabNet3!==n (
set /p LabelISO=請插入光盤或者裝載ISO,并準確輸入盤符!----
)
)
if !bIsWin8!==n (
set bDisabFun=y
set /p bDisabFun=請問是否關閉Win7部分功能?默認是y,直接回車/不是輸入小寫n----
set bDismIE10=y
set /p bDismIE10=請問是否封裝IE10?默認是y,直接回車/不是輸入小寫n----
)
::準備源系統(tǒng)映像文件與索引序號。
set bHvLSr=n
for /l %%i in (1,1,5) do (
if !bHvLSr!==n (
set /p LPartSource=請輸入系統(tǒng)映像文件所在盤,不帶冒號----
if not exist !LPartSource!: echo 這個盤符根本就沒有使用了,你不要搞笑好吧
if exist !LPartSource!: set bHvLSr=y
)
)
dir !LPartSource!:\*.wim /b /s >%temp%\fSeek.txt
echo 查找到!LPartSource!分區(qū)下所有映像文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do ( set /a a+=1&&echo 系統(tǒng)映像:!a! %%i)
set /a CountWim=!a!
if !a!==0 echo 該分區(qū)無系統(tǒng)映像文件,退出重來吧!&&goto End
::準備臨時文件夾\tmp_Imagex,預備以后作為ScratchDir使用,這段代碼不能隨意移動位置!
::目的是1:在PE中臨時文件空間不足,源文件盤空間一般沒問題;2:如果源文件在固態(tài)盤,要充分固態(tài)盤速度優(yōu)勢。
if not exist !LPartSource!:\tmp_Imagex md !LPartSource!:\tmp_Imagex
if exist !LPartSource!:\tmp_Imagex rd /s /q !LPartSource!:\tmp_Imagex&&md !LPartSource!:\tmp_Imagex
::準備局部文件夾\mount
if not exist !LPartSource!:\mount md !LPartSource!:\mount
if exist !LPartSource!:\mount (
:rd
dir !LPartSource!:\mount /ad /b /s >%temp%\del_rd.txt
for /f "usebackq delims=" %%i in (%temp%\del_rd.txt) do ((takeown /f "%%i" /r /d y >%temp%\del_log.txt>nul 2>nul)&(@echo y|icacls "%%i" /t /q /grant administrator:f>nul 2>nul )&(rd "%%i" /s /q>nul 2>nul))
takeown /f !LPartSource!:\mount /r /d y >%temp%\del_log.txt>nul 2>nul
@echo y|icacls !LPartSource!:\mount /t /q /grant administrator:f>nul 2>nul
rd !LPartSource!:\mount /s /q
if exist !LPartSource!:\mount goto :rd
del /f /s /q %temp%\del_log.txt>nul 2>nul
del /f /s /q %temp%\del_rd.txt>nul 2>nul
md !LPartSource!:\mount
)
set /p NumWimSource=請輸入系統(tǒng)映像文件序號,我不檢測無效序號,不帶冒號----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效系統(tǒng)映像文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !NumWimSource!==!a! Dism /get-imageinfo /imagefile:%%i
)
set /p IndexSource=請輸入系統(tǒng)映像索引序號,我不檢測無效序號,不帶冒號----
if not !bPatDism!==n (
cls
set /a a=0
dir %~dp0patch /d /b >%temp%\dirPatSeek.txt
echo 查找到%~dp0patch目錄下所有子目錄,僅查子目錄
for /f "usebackq delims=" %%i in (%temp%\dirPatSeek.txt) do (
set /a a+=1
echo 所有子目錄:!a! %%i)
set /a CountPatch=!a!
if !CountPatch!==0 echo 無任何patch子目錄&&set bPatDism=n
echo -----------------------------------------------------
if not !CountPatch!==0 (
set /p NumPatch=請輸入patch子目錄序號,不帶冒號----
set bVldPat=n
for /l %%i in (1,1,!CountPatch!) do (
if !NumPatch!==%%i set bVldPat=y
)
if !bVldPat!==n echo 你沒有輸入有效patch子目錄序號,退出重來吧!&&goto End
)
)
if not !bDrvDism!==n (
cls
set /a a=0
dir %~dp0Driver /d /b >%temp%\dirDrvSeek.txt
echo 查找到%~dp0Driver目錄下所有子目錄,僅查子目錄
for /f "usebackq delims=" %%i in (%temp%\dirDrvSeek.txt) do (
set /a a+=1
echo 所有子目錄:!a! %%i)
set /a CountDrv=!a!
if !CountDrv!==0 echo 無任何Driver子目錄&&set bDrvDism=n
echo -----------------------------------------------------
if not !CountDrv!==0 (
set /p NumDrv=請輸入patch子目錄序號,不帶冒號----
set bVldDrv=n
for /l %%i in (1,1,!CountDrv!) do (
if !NumDrv!==%%i set bVldDrv=y
)
if !bVldDrv!==n echo 你沒有輸入有效Driver子目錄序號,退出重來吧!&&goto End
)
)
if !bIsWin8!==n (
if not !bDismIE10!==n (
echo IE10升級包在當前目錄子目錄IE下!
set /a a=0
dir %~dp0IE /d /b >%temp%\dirIESeek.txt
echo 查找到%~dp0IE目錄下所有子目錄,僅查子目錄
for /f "usebackq delims=" %%i in (%temp%\dirIESeek.txt) do (
set /a a+=1
echo 所有子目錄:!a! %%i)
set /a CountIE=!a!
if !CountIE!==0 echo 無任何IE子目錄&&set bDismIE10=n
echo -----------------------------------------------------
if not !CountIE!==0 (
set /p NumIE=請輸入IE子目錄序號,不帶冒號----
set bVldIE=n
for /l %%i in (1,1,!CountIE!) do (
if !NumIE!==%%i set bVldIE=y
)
if !bVldIE!==n echo 你沒有輸入有效IE子目錄序號,退出重來吧!&&goto End
)
)
)
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !NumWimSource!==!a! dism /mount-image /imagefile:"%%i" /index:!IndexSource! /mountdir:!LPartSource!:\mount /Scratchdir:!LPartSource!:\tmp_Imagex
)
if not !bPatDism!==n (
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\dirPatSeek.txt) do (
set /a a+=1
if !NumPatch!==!a! dir "%~dp0patch\%%i" /b /s >%temp%\fPatSeek.txt
)
for /f "usebackq delims=" %%j in (%temp%\fPatSeek.txt) do ( dism /image:!LPartSource!:\mount /add-package /packagepath:%%j /Scratchdir:!LPartSource!:\tmp_Imagex )
)
if not !bDrvDism!==n (
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\dirDrvSeek.txt) do (
set /a a+=1
if !NumDrv!==!a! dism /image:!LPartSource!:\mount /add-driver /driver:"%~dp0Driver\%%i" /recurse /forceunsigned /Scratchdir:!LPartSource!:\tmp_Imagex
)
)
if not !bIsWin8!==n (
if not !bEnabNet3!==n (
dism /image:!LPartSource!:\mount /enable-Feature /FeatureName:netfx3 /Source:!LabelISO!:\sources\sxs /Scratchdir:!LPartSource!:\tmp_Imagex
)
)
if !bIsWin8!==n (
if not !bDisabFun!==n (
echo 調(diào)整功能獨立操作,以增強批處理兼容性,連Win7 Starter都可以用。
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:TabletPCOC
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:WindowsGadgetPlatform
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:MediaCenter
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:FaxServicesClientPackage
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Printing-XPSServices-Features
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Xps-Foundation-Xps-Viewer
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Printing-Foundation-InternetPrinting-Client
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Hearts
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Solitaire
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:SpiderSolitaire
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:FreeCell
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Minesweeper
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:PurblePlace
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Chess
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:Shanghai
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:InboxGames
dism /Image:!LPartSource!:\mount /Disable-Feature /Scratchdir:!LPartSource!:\tmp_Imagex /FeatureName:OpticalMediaDisc
)
if not !bDismIE10!==n (
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\dirIESeek.txt) do (
set /a a+=1
if !NumIE!==!a! (
dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\ie-win7.cab /packagepath:%~dp0ie\%%i\ielangpack-CHS.CAB /Scratchdir:!LPartSource!:\tmp_Imagex
dism /image:!LPartSource!:\mount /add-package /packagepath:%~dp0ie\%%i\IE-Hyphenation-NEU.msu /packagepath:%~dp0ie\%%i\IE-Spelling-NEU.msu /Scratchdir:!LPartSource!:\tmp_Imagex
)
)
)
)
set /p bCommit=請問是否保存映像修改,默認是y,直接回車/不保存輸入小寫n----
if not !bCommit!==n ( dism /unmount-image /mountdir:!LPartSource!:\mount /commit /Scratchdir:!LPartSource!:\tmp_Imagex )
if !bCommit!==n ( dism /unmount-image /mountdir:!LPartSource!:\mount /discard /Scratchdir:!LPartSource!:\tmp_Imagex )
rd /s /q !LPartSource!:\tmp_Imagex
rd /s /q !LPartSource!:\mount
goto End
)
if !OpChoice!==14 (
echo 查找同目錄(及子目錄)下自動應答文件,如果一個都沒有,那就不要試了。
echo 本工具包提供的自動應答文件分64位和32位兩種,通用版僅僅實現(xiàn)跳過oobe過程。
set /a NumUntitled=0
set /a a=0
set NameUntitled=null
dir %~dp0*.xml /b /s >%~dp0fAppUntitled.txt
echo 查找到%~dp0目錄下所有自動應答文件如下表
echo -----------------------------------------------------
for /f "usebackq delims=" %%i in (%~dp0fAppUntitled.txt) do ( set /a a+=1&&echo 應答文件:!a! %%i)
if !a!==0 echo 根本就沒有一個自動應答文件,那封裝也沒什么意思了,準備退出!&&goto End
echo.
set /p NumUntitled=請認真選擇應答文件序號,不帶冒號----
set /a a=0
for /f "usebackq delims=" %%i in (%~dp0fAppUntitled.txt) do (
set /a a+=1
if !NumUntitled!==!a! echo 你選擇的應答文件是:%%i
)
set bGoSysprep=y
set /p bGoSysprep=最后請確認現(xiàn)在可以開始封裝了嗎?默認是,直接回車,如果算了,請輸入小寫n----
if not !bGoSysprep!==n (
echo 正在幫您清除系統(tǒng)垃圾文件,請稍等......
::刪除補丁備份目錄
rd %windir%\$hf_mig$ /Q /S
::刪除系統(tǒng)盤Office安裝臨時文件
rd /s /q %systemdrive%\msocache
dir /ad /b /s %windir%\$NtUninstall* >%~dp0Del_rd.txt
dir /ad /b /s %windir%\SoftwareDistribution\Download>>%~dp0Del_rd.txt
for /f %%i in (%~dp0Del_rd.txt ) do ( rd "%%i" /s /q )
del %~dp0Del_rd.txt /f /q
::刪除補丁安裝記錄內(nèi)容(下面的del /f /s /q %systemdrive%\*.log已經(jīng)包含刪除此類文件)
del %windir%\KB*.log /f /q
::刪除系統(tǒng)盤目錄下臨時文件
del /f /s /q %windir%\*.tmp
::刪除系統(tǒng)盤目錄下臨時文件
del /f /s /q %windir%\*._mp
::刪除系統(tǒng)盤目錄下日志文件
del /f /s /q %windir%\*.log
::刪除系統(tǒng)盤目錄下GID文件
del /f /s /q %windir%\*.gid
::刪除系統(tǒng)目錄下scandisk(磁盤掃描)留下的無用文件
del /f /s /q %windir%\*.chk
::刪除系統(tǒng)目錄下old文件
del /f /s /q %windir%\*.old
::刪除回收站的無用文件
del /f /s /q %windir%\recycled\*.*
::刪除系統(tǒng)目錄下備份文件
del /f /s /q %windir%\*.bak
::刪除系統(tǒng)維護等操作產(chǎn)生的臨時文件
rd /s /q %windir%\temp md %windir%\temp
::刪除當前用戶的COOKIE(IE)
del /f /q %userprofile%\cookies\*.*
::刪除internet臨時文件
del /f /s /q "%userprofile%\local settings\temporary internet files\*.*"
::刪除當前用戶日常操作臨時文件
del /f /s /q "%userprofile%\local settings\temp\*.*"
copy %systemdrive%\Users\%username%\Favorites\*.* %systemdrive%\Users\Default\Favorites
dir %~dp0Desk*.bat /b /s >%~dp0fTmp.txt
dir %~dp0Driver*.bat /b /s >>%~dp0fTmp.txt
for /f %%i in (%~dp0fTmp.txt) do ( copy %%i %windir%\system32 )
set /a a=0
for /f "usebackq delims=" %%i in (%~dp0fAppUntitled.txt) do (
set /a a+=1
if !a!==!NumUntitled! %windir%\system32\sysprep\sysprep.exe /oobe /generalize /shutdown /unattend:%%i
)
)
goto End
)
if !OpChoice!==15 (
set bIsUEFI=y
set /p bIsUEFI=請問BIOS是否UEFI,默認是,不是請輸入小寫n----
set bHvLab=n
set /p bHvLab=采用MBR但無MSR,或者MBR中MSR分區(qū)/ESP分區(qū)如已有盤符,輸入y,其余直接回車----
if !bHvLab!==y (
set /p LabelEFI=請輸入ESP分區(qū)或MBR中MSR分區(qū)盤符或者MBR無MSR分區(qū)時的系統(tǒng)盤符----
)
if not !bHvLab!==y (
::給EFI或者MSR分區(qū)分配盤符
set bHvSetESP=n
for %%i in (z y x w v u t s r q p o n m) do (
if !bHvSetESP!==n ( if not exist %%i: set LabelEFI=%%i&&set bHvSetESP=y )
)
echo list vol>%temp%\DiskPart.txt
echo exit>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
set /p NumVolESP=請輸入GPT中ESP分區(qū)或MBR中MSR分區(qū)的卷編號,直接回車----
echo select vol !NumVolESP!>%temp%\DiskPart.txt
echo assign letter=!LabelEFI!>>%temp%\DiskPart.txt
echo exit>>%temp%\DiskPart.txt
diskpart /s %temp%\DiskPart.txt
)
bcdedit /create {bootmgr} /d "Marc Boot Manager" >nul 2>nul
bcdedit /set {bootmgr} device partition=\device\harddiskvolume!NumVolESP! >nul 2>nul
set b8Boot=n
set /p b8Boot=請問是否建8.1/8/7引導,默認不,如果要建輸入小寫y----
if !b8Boot!==y (
::創(chuàng)建8.1/8/7引導項
set l_Sys8=null
set /p l_Sys8=請問要為哪個盤的Windows 8.1/8/7建立引導,輸入盤符----
set name_MenuWindows=Windows_8.1/8/7
set /p name_MenuWindows=默認菜單項名字Windows_8.1/8/7,可自行輸入不帶空格名字,如Windows_7----
bcdedit /create /d "!name_MenuWindows!" /application osloader>%temp%\fmid.txt
for /f "tokens=2 delims= " %%i in (%temp%\fmid.txt) do (set fmid=%%i)
bcdedit /set !fmid! device partition=!l_Sys8!:
if not !bIsUEFI!==n bcdedit /set !fmid! path \windows\system32\winload.efi
if !bIsUEFI!==n bcdedit /set !fmid! path \windows\system32\winload.exe
bcdedit /set !fmid! osdevice partition=!l_Sys8!:
bcdedit /set !fmid! systemroot \windows
bcdedit /displayorder !fmid! /addlast
)
set b8VhdBoot=n
set /p b8VhdBoot=請問是否建8.1/8/7 VHD引導,默認不,如果要建輸入小寫y----
if !b8VhdBoot!==y (
::創(chuàng)建8.1/8/7 VHD引導項
set namePathVhd=null
::準備VHD系統(tǒng)文件與序號。
set bHvLSr=n
for /l %%i in (1,1,5) do (
if !bHvLSr!==n (
set /p LPartSource=請輸入VHD系統(tǒng)文件所在盤,不帶冒號----
if not exist !LPartSource!: echo 這個盤符根本就沒有使用了,你不要搞笑好吧
if exist !LPartSource!: set bHvLSr=y
)
)
dir !LPartSource!:\*.vhd /b /s >%temp%\fSeek.txt
echo 查找到!LPartSource!分區(qū)下所有VHD文件如下表
echo -----------------------------------------------------
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do ( set /a a+=1&&echo 系統(tǒng)映像:!a! %%i)
set /a CountWim=!a!
if !a!==0 echo 該分區(qū)無系統(tǒng)VHD文件,退出重來吧!&&goto End
set NumWimSource=1
set /p NumWimSource=請輸入VHD系統(tǒng)文件序號,我不檢測無效序號,默認1----
set bVldNSr=n
for /l %%i in (1,1,!CountWim!) do ( if !NumWimSource!==%%i set bVldNSr=y )
if !bVldNSr!==n echo 你沒有輸入有效VHD系統(tǒng)文件序號,退出重來吧!&&goto End
set /a a=0
for /f "usebackq delims=" %%i in (%temp%\fSeek.txt) do (
set /a a+=1
if !a!==!NumWimSource! (
set nameTmp=%%i
echo 你選擇的VHD系統(tǒng)文件是:%%i
)
)
set namePathVhd=!nameTmp:~3!
set name_MenuVHD=VHD_MBY
set /p name_MenuVHD=輸入菜單項名字,默認VHD_MBY,可自行輸入,如MAXDOS_WYS----
bcdedit /create /d "!name_MenuVHD!" /application osloader>%temp%\fmid.txt
for /f "tokens=2 delims= " %%i in (%temp%\fmid.txt) do (set fmid=%%i)
bcdedit /set !fmid! device vhd=[!LPartSource!:]\!namePathVhd!
if not !bIsUEFI!==n bcdedit /set !fmid! path \windows\system32\winload.efi
if !bIsUEFI!==n bcdedit /set !fmid! path \windows\system32\winload.exe
bcdedit /set !fmid! osdevice vhd=[!LPartSource!:]\!namePathVhd!
bcdedit /set !fmid! systemroot \windows
bcdedit /set !fmid! detecthal yes
bcdedit /displayorder !fmid! /addlast
)
if !bIsUEFI!==n (
set bXP=n
set /p bXP=請問是否建XP引導,默認不,如果要建輸入小寫y----
if !bXP!==y (
::創(chuàng)建XP引導項
set l_SysXP=null
set /p l_SysXP=請問要為哪個盤的XP建立引導,輸入盤符----
set name_MenuXP=XP_MBY
set /p name_MenuXP=輸入菜單項名字,默認XP_MBY,可自行輸入,如MAXDOS_WYS----
bcdedit /create {ntldr} /d "!name_MenuXP!"
bcdedit /set {ntldr} device partition=!l_SysXP!:
bcdedit /set {ntldr} path \ntldr
bcdedit /displayorder {ntldr} /addlast
)
)
goto End
)
if !OpChoice!==16 (
echo.
bcdedit /enum /v >%temp%\x.txt
::取得GUID所在行。
set numOrder=null
set /a a=0
for /f "delims= " %%i in ( %temp%\x.txt ) do (
set /a a+=1
if %%i==displayorder set numOrder=!a!
)
find "description" %temp%\x.txt >%temp%\m.txt
set /a a=0
for /f "skip=3 tokens=1,* delims= " %%i in ( %temp%\m.txt ) do (
set bDel=n
set /a Tmp=!a!+1
set /p bDel=系統(tǒng)啟動菜單第!Tmp!項是:%%j,請問是否刪除,默認不刪,刪除輸入y----
set /a numItem=!a!+!numOrder!
if not !bDel!==n (
set /a c=0
for /f "tokens=1,* delims= " %%k in ( %temp%\x.txt ) do (
set /a c+=1
if !c!==!numItem! (
if !numItem!==!numOrder! (
set item=%%l
bcdedit /delete %%l >nul 2>nul
bcdedit /delete %%l /f >nul 2>nul
)
if not !numItem!==!numOrder! (
set item=%%k
bcdedit /delete %%k >nul 2>nul
bcdedit /delete %%k /f >nul 2>nul
)
)
)
)
set /a a+=1
)
del /f /s /q %temp%\x.txt>nul 2>nul
del /f /s /q %temp%\m.txt>nul 2>nul
bcdedit /enum
echo.
goto End
)
:End
set bProceed=n
set /p bProceed=請問繼續(xù)其它任務嗎,重復運行默認應答選項有效,默認不n,直接回車/是輸入小寫y----
if !bProceed!==y goto op
del /f /s /q %temp%\fSeek.txt>nul 2>nul
del /f /s /q %temp%\fSrSeek.txt>nul 2>nul
del /f /s /q %temp%\fDsSeek.txt>nul 2>nul
del /f /s /q %temp%\dirPatSeek.txt>nul 2>nul
del /f /s /q %temp%\dirDrvSeek.txt>nul 2>nul
del /f /s /q %temp%\dirIESeek.txt>nul 2>nul
del /f /s /q %temp%\fPatSeek.txt>nul 2>nul
del /f /s /q %temp%\ImageInfo.txt>nul 2>nul
del /f /s /q %temp%\DiskPart.txt>nul 2>nul
del /f /s /q %temp%\tmp.txt>nul 2>nul
del /f /s /q %~dp0fAppUntitled.txt>nul 2>nul
del /f /s /q %~dp0fTmp.txt>nul 2>nul
del /f /s /q %~dp0null>nul 2>nul
del /f /s /q %temp%\Out_DiskPart.txt>nul 2>nul
del /f /s /q %temp%\Out_tmp.txt>nul 2>nul
del /f /s /q %temp%\tmp.txt>nul 2>nul
del /f /s /q %~dp0fdid.txt>nul 2>nul
del /f /s /q %~dp0fmid.txt>nul 2>nul
echo 任務結束時間是%time:~,2%點%time:~3,2%分%time:~6,2%秒
set "T2=%time%"
if "%T2:~,2%" lss "%T1:~,2%" (set Tday+=8640000)
set /a "T_d=%Tday%+(%T2:~,2%*360000)+(%T2:~3,1%*60000+%T2:~4,1%*6000)+(%T2:~6,1%*1000+%T2:~7,1%*100)+(%T2:~9,1%*10+%T2:~-1%)-(%T1:~,2%*360000)-(%T1:~3,1%*60000+%T1:~4,1%*6000)-(%T1:~6,1%*1000+%T1:~7,1%*100)-(%T1:~9,1%*10+%T1:~-1%)"
set /a "ss=%T_d%/100%%60"
set /a "mm=%T_d%/6000%%60"
set /a "hh=%T_d%/360000%%1"
set /a "ms=%T_d%%%100"
echo 本次任務消耗時間為 %hh%:%mm%:%ss%.%ms%秒
pause
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權內(nèi)容,請
點擊舉報。