|
本帖最后由 gxbcm 于 2024-4-11 16:38 编辑
@echo off
mode con cols=90 lines=26
:: 批处理获取管理员权限
:-------------------------
%1 mshta vbscript:createobject("shell.application").shellexecute("""%~0""","::",,"runas",1)(window.close)&&exit /b
pushd "%CD%"
CD /D "%~dp0"
:-------------------------
SET WE=ESD
SET KK=--wimboot
SET KK2=切换ESD-WIM界面
for %%a in (C D E F G H I J K L M ) do (
SET SNADIR=%%a:\SNAP\
SET DIRSD=%%a:
IF exist %%a:\SNAP\ GOTO MENU
IF exist %%a: SET n1=%%a
)
SET DIRS=%n1%
SET /P DIRS= 请输入备份存放工作盘(C-%DIRS%)字母 回车:
SET SNADIR=%DIRS%:\SNAP\
MD %SNADIR%
GOTO MENU
EXIT
:MENU
CLS
SET DIRS=C:
IF "%KK%"=="OFF1" (
SET KK1=关闭
SET KK=OFF1
) ELSE (
SET KK1=开启
SET KK=--wimboot
)
IF NOT EXIST %SNADIR%SYSC.%WE% (
SET DR=找不到SYSC.%WE% 镜像
GOTO PASS
)
title WIMLIB-IMAGEX 系统备份恢复
IF EXIST %SNADIR%SYSC.ESD wimlib-imagex.exe info %SNADIR%SYSC.ESD>ESD.txt
IF EXIST %SNADIR%SYSC.ESD findstr "Image Count:" ESD.TXT >ESD1.TXT & SET /P EAA=<./ESD1.TXT
IF EXIST %SNADIR%SYSC.WIM wimlib-imagex.exe info %SNADIR%SYSC.WIM>WIM.txt
IF EXIST %SNADIR%SYSC.WIM findstr "Image Count:" WIM.TXT >WIM1.TXT & SET /P WAA=<./WIM1.TXT
IF %WE% equ ESD (
SET /A AA1=%EAA:~16,1%
) ELSE (
SET /A AA1=%WAA:~16,1%
)
for /l %%i in (1,1,%AA1%) do (
set /a AA2=%%i
)
:PASS
SET /A Bn=AA2+1
SET /A Hn=AA2
IF EXIST %SNADIR%SYSC.%WE% SET DR=%SNADIR%SYSC.%WE% 文件中有%Hn%个备份镜像
color 1f
echo.
echo. 备份目录%SNADIR%中存在的%WE%映像文件
echo.==============================
echo. %DR%
echo.==============================
echo. WIMLIB-IMAGEX 备份恢复系统--%WE%文件
echo. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
echo. [5] 一键自动备份系统
echo.
echo. [0] 一键自动恢复系统
echo.
echo. [9] 选择盘符恢复系统
echo.
echo. [8] 删除一个增量备份
echo.
echo. [2] 查看备份%SNADIR%目录
echo. ------------------------------------------------------------
echo. [E]退出 [G]%KK2% [P]参数wimboot %KK1%
echo. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
SET ST1=2
SET /P ST1= 请输入选项(默认:%ST1%)回车:
if /I "%ST1%"=="5" goto winbackup
if /I "%ST1%"=="0" goto winrecover
if /I "%ST1%"=="2" goto folderopen
if /I "%ST1%"=="9" goto XZ
if /I "%ST1%"=="8" goto SC
if /I "%ST1%"=="e" goto exit
if /I "%ST1%"=="P" GOTO KSK
if /I "%ST1%"=="G" IF %WE% equ ESD (SET WE=WIM
SET KK2=切换WIM-ESD界面
) ELSE (
SET WE=ESD
SET KK2=切换ESD-WIM界面
)
GOTO MENU
EXIT
:XZ
for %%b in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
IF exist %%b: SET k1=%%b
)
SET DIRS1=C
SET /P DIRS1= 请输入需要恢复目标盘符 默认C:盘 (请输入C-%K1%)字母 回车:
SET DIRS2=%DIRS1%:
IF %DIRS2% equ %DIRSD% (
ECHO. 与备份盘一致重新选择盘符
GOTO XZ
)
SET DIRS=%DIRS1%:
SET KK=OFF1
SET KK1=关闭
GOTO winrecover
EXIT
:KSK
IF "%KK%"=="--wimboot" (SET KK=OFF1
) ELSE (
SET KK= --wimboot
)
GOTO MENU
EXIT
:SC
SET ST7=%Hn%
SET /P ST7= 按E键-返回主菜单 默认删除SYSC.%WE% (默认第%Hn%个备份 输入1-%Hn%数字) 回车:
if /I "%ST7%"=="e" goto MENU
IF NOT EXIST %SNADIR%SYSC.%WE% GOTO MENU
"wimlib-imagex.exe" delete %SNADIR%SYSC.%WE% %Hn% --soft
PAUSE
GOTO MENU
:winbackup
IF NOT EXIST %SNADIR%SYSC.%WE% GOTO BACKUP1
SET ST9=%Bn%
SET /P ST9= 按E键-返回主菜单 默认备份SYSC.%WE% (默认第%Bn%个备份 输入%Bn%-9数字) 回车:
if /I "%ST9%"=="e" goto MENU
if /I "%ST9%"=="1" goto BACKUP1
IF EXIST "X:\WINDOWS\" "wimlib-imagex.exe" append C:\ %SNADIR%SYSC.%WE% %ST9% %ST9%
IF NOT EXIST "X:\WINDOWS\" "wimlib-imagex.exe" append C:\ %SNADIR%SYSC.%WE% %ST9% %ST9% --snapshot
PAUSE
GOTO MENU
exit
:BACKUP1
SET ST0=0
SET /P ST0= 按E键-返回主菜单 默认备份SYSC.%WE% 回车:
if /I "%ST0%"=="e" goto MENU
if %WE% equ ESD (
IF EXIST "X:\WINDOWS\" "wimlib-imagex.exe" capture C:\ %SNADIR%SYSC.%WE% 1 1 --compress=LZX:20 --check
IF NOT EXIST "X:\WINDOWS\" "wimlib-imagex.exe" capture C:\ %SNADIR%SYSC.%WE% 1 1 --snapshot --compress=LZX:20 --check
) ELSE (
IF EXIST "X:\WINDOWS\" "wimlib-imagex.exe" capture C:\ %SNADIR%SYSC.%WE% 1 1 --compress=XPRESS --check
IF NOT EXIST "X:\WINDOWS\" "wimlib-imagex.exe" capture C:\ %SNADIR%SYSC.%WE% 1 1 --snapshot --compress=XPRESS --check
)
pause
GOTO MENU
EXIT
:winrecover
echo. 进入PE中恢复系统 恢复到%DIRS%盘 参数wimboot %KK1%
set ST4=%Hn%
SET /P ST4= 按E键-返回主菜单 默认恢复SYSC.%WE% (默认第%Hn%个恢复 输入1-%ST4%数字) 回车:
IF NOT EXIST "X:\WINDOWS\" GOTO MENU
IF NOT EXIST %SNADIR%SYSC.%WE% GOTO MENU
if /I "%ST4%"=="e" goto MENU
FORMAT %DIRS% /Q /Y
IF "%KK%"=="--wimboot" (
"wimlib-imagex.exe" apply %SNADIR%SYSC.%WE% %ST4% %DIRS% --wimboot
) ELSE (
"wimlib-imagex.exe" apply %SNADIR%SYSC.%WE% %ST4% %DIRS%
)
GOTO MENU
EXIT
:folderopen
DIR %SNADIR%
pause
GOTO MENU
exit
强迫症,必须把BUG全部解决了,又跟新了一下,这次没有BUG了。按照这个思路,有兴趣的搞GUI脚本吧。
|
|