@echo off
title ◇傻瓜备份还原系统1.5◇
set cd1=%cd%
:start
cls
set tm1=%time:~0,2%
set tm2=%time:~3,2%
set tm3=%time:~6,2%
echo ╔┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╗
echo.┋ %date% %tm1%点%tm2%分 by QQ25969805 ┋
echo.┋ ┋
echo ┋ 〖1.还原系统〗 ┋
echo ┋ 〖2.备份系统〗 ┋
echo ┋ 〖3.优化设置〗 ┋
echo.┋ ┋
echo.┋ ╔┉┉┉┉┉┉┉┉┉┉┉┋
echo ┋ ┋Z.退出程序┋M.程序简介┋
echo.╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
echo ┏━━━━━━━━━━━━━┓
echo ┃请输入你想要的数字后回车: ┃
echo ┗━━━━━━━━━━━━━┛
set choice=
set /p choice=
if /i "%choice%"=="1" goto resconver
if /i "%choice%"=="2" goto bak
if /i "%choice%"=="3" goto basicset
if /i "%choice%"=="m" goto readme
if /i "%choice%"=="Z" goto end
echo ┌────────────┐
echo │按任意键开始还原系统... │
echo └────────────┘
set choice=
set /p choice=
if /i "%choice%"=="n" goto start
if /i "%choice%"=="q" goto end
goto resconver
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:bak
set image=0
set nofile=0
set driver=f
goto check
:nextcheckf
set driver=e
goto check
:nextchecke
set driver=d
goto check
:nextcheckd
echo ┌──────────┐
echo │ 检查可用磁盘空间...│
echo └──────────┘
set nofile=1
set driver=f
goto check
:nofilerecive
if %check% NEQ 1 goto nextcheckn%driver%
goto ok%driver%
:recive
if %check% NEQ 1 goto nextcheck%driver%
if %existghostfile% NEQ 1 goto nextcheck%driver%
goto ok%driver%
:okf
echo ┌──────────┐
echo │开始备份至%driver%盘│
echo └──────────┘
set image=fb
goto function
:oke
echo ┌──────────┐
echo │开始备份至%driver%盘│
echo └──────────┘
set image=eb
goto function
:okd
echo ┌──────────┐
echo │开始备份至%driver%盘│
echo └──────────┘
set image=db
goto function
exit
goto :eof
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:check
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "可用字节"') do set c=%%c
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "可用字节"') do set d=%%d
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "可用字节"') do set e=%%e
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "可用字节"') do set f=%%f
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "可用字节"') do set g=%%g
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "可用字节"') do set h=%%h
echo %d% | find "字节" >nul
if %ERRORLEVEL% neq 0 goto nexte
set space=%c%
:nexte
echo %e% | find "字节" >nul
if %ERRORLEVEL% neq 0 goto nextf
set space=%c%%d%
set /a space=%space%/1024/1024
:nextf
echo %f% | find "字节" >nul
if %ERRORLEVEL% neq 0 goto nextg
set space=%c%%d%%e%
set /a space=%space%/1024/1024
:nextg
echo %g% | find "字节" >nul
if %ERRORLEVEL% neq 0 goto nexth
set space=%d%%e%%f%
set /a space=%space%/1024/1024
set t=%c%
set /a t=%t%*953
set /a space+=%t%
:nexth
echo %h% | find "字节" >nul
if %ERRORLEVEL% neq 0 goto nextx
set space=%c%%d%%e%%f%%g%
set space=%d%%e%%f%
set /a space=%space%/1024/1024
set t=%c%%d%
set /a t=%t%*953
set /a space+=%t%
:nextx
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::get the ghost file size
%driver%:
cd %driver%:\
dir ghost /d |find "ghost" >nul
cls
set /a n=0
set existghostfile=0
if %ERRORLEVEL% NEQ 0 goto skipghostfile
set existghostfile=1
for /R "%driver%:\ghost" %%i in (*) do set /a n+=%%~zi
set /a n=%n%/1024/1024
echo %n%M in %driver%:\ghost
:skipghostfile
echo %space%M in %driver%: free
set /a space+=%n%
echo %space%M in %driver%: freesize
set check=0
if %space% gtr 2048 set check=1
if %nofile%==1 goto nofilerecive
goto recive
:bak1
if "%image%"=="fb" copy "%cd1%\ghost\ghost\fb\ghost.img" c:\boot\grub\ /y
if "%image%"=="eb" copy "%cd1%\ghost\ghost\fb\ghost.img" c:\boot\grub\ /y
if "%image%"=="db" copy "%cd1%\ghost\ghost\db\ghost.img" c:\boot\grub\ /y
if "%image%"=="0" echo error 请联系QQ25969805
cls
echo ┌─────┐
echo │load...ok`│
echo └─────┘
echo ┌───────────────────────────┐
echo │系统将在10秒钟后自动重启。如果没有自动重启。请手动重启│
echo └───────────────────────────┘
%SystemRoot%\system32\shutdown /r /t 10 /c "即将备份c盘至%driver%:\ghost\ghost"
echo ┌───────────────┐
echo │取消重启请按Q.按任意键立即重启│
echo └───────────────┘
set choice=
set /p choice=
if /i "%choice%"=="q" goto en
shutdown /a
ping 127.1>nul
::for /l %%a in (1,1,15) do shutdown /r /t 0
shutdown /r /t 0
ping 127.1>nul
shutdown /r /t 0
ping 127.1>nul
shutdown /r /t 0
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:resconver
set osf=0
set driver=f
goto checkss
:chkgho
echo ┌───────┐
echo │正在搜索%driver%盘...│
echo └───────┘
for /f "tokens=1 delims=," %%a in ('dir %driver%:\*.gho /s ^| find /i "的目录"') do set p=%%a
set /a ytest=%p%+1
if %ytest%==1 goto chkgho%driver%
cls
echo ┌───────────┐
echo │开始搜索本地gho文件...│
echo └───────────┘
echo ┌─────────────┐
echo │这可能需要几分钟的时间... │
echo └─────────────┘
echo ┌─────┐
echo │请稍等... │
echo └─────┘
for /f "tokens=1-9" %%a in ("%p%") do set a=%%a
for /f "tokens=1-9" %%a in ("%p%") do set b=%%b
for /f "tokens=1-9" %%a in ("%p%") do set c=%%c
if %errorlevel%==1 goto sult1
for /f "tokens=1-9" %%a in ("%p%") do set d=%%d
if %errorlevel%==1 goto sult2
for /f "tokens=1-9" %%a in ("%p%") do set e=%%e
if %errorlevel%==1 goto sult3
for /f "tokens=1-9" %%a in ("%p%") do set f=%%f
if %errorlevel%==1 goto sult4
for /f "tokens=1-9" %%a in ("%p%") do set g=%%g
if %errorlevel%==1 goto sult5
for /f "tokens=1-9" %%a in ("%p%") do set h=%%h
if %errorlevel%==1 goto sult6
for /f "tokens=1-9" %%a in ("%p%") do set i=%%i
if %errorlevel%==1 goto sult7
goto sult8
:sult1
set slut=%a%
goto sultend
:sult2
set slut=%a% %b%
goto sultend
:sult3
set slut=%a% %b% %c%
goto sultend
:sult4
set slut=%a% %b% %c% %d%
goto sultend
:sult5
set slut=%a% %b% %c% %d% %e%
goto sultend
:sult6
set slut=%a% %b% %c% %d% %e% %f%
goto sultend
:sult7
set slut=%a% %b% %c% %d% %e% %f% %g%
goto sultend
:sult8
set slut=%a% %b% %c% %d% %e% %f% %g% %h%
goto sultend
:sultend
for /f "tokens=4-8" %%a in ('dir "%slut%" ^| find /i ".gho"') do set gho1=%%a %%b %%c %%d %%e
set ghopath=%slut%\%gho1%
echo %ghopath%
if not exist %driver%:\ghost md %driver%:\ghost
move "%ghopath%" %driver%:\ghost\ghost
echo ╔┉┉┉
echo ┋已经将"%ghopath%" 转移至 "%driver%:\ghost\ghost"!
echo ╚┉┉┉
ping 127.1>nul
echo ┌────────┐
echo │开始还原系统... │
echo └────────┘
ping 127.1>nul
goto resconver
exit
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
goto :eof
:checkss
Attrib -s -r -h %driver%:\recycler
del %driver%:\recycler\*.gho /s /q
cls
set /a n=0
for /R "%driver%:\ghost" %%i in (*) do set /a n+=%%~zi
set /a n=%n%/1024/1024
if not exist %driver%:\ghost\ghost goto nexts%driver%
if %n% LEQ 300 goto nexts%driver%
goto oks%driver%
:oksf
set osf=fs
goto function
:okse
set osf=es
goto function
:oksd
set osf=ds
goto function
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:resconver1
if "%osf%"=="fs" copy "%cd1%\ghost\ghost\fs\ghost.img" c:\boot\grub\ /y
if "%osf%"=="es" copy "%cd1%\ghost\ghost\es\ghost.img" c:\boot\grub\ /y
if "%osf%"=="ds" copy "%cd1%\ghost\ghost\ds\ghost.img" c:\boot\grub\ /y
cls
echo ┌─────┐
echo │load...ok`│
echo └─────┘
echo ┌───────────────────────────┐
echo │系统将在10秒钟后自动重启。如果没有自动重启。请手动重启│
echo └───────────────────────────┘
%SystemRoot%\system32\shutdown /r /t 10 /c "即将还原%driver%:\ghost\ghost至c盘"
echo ┌───────────────┐
echo │取消重启请按Q.按任意键立即重启│
echo └───────────────┘
set choice=
set /p choice=
if /i "%choice%"=="q" goto en
shutdown /a
ping 127.1>nul
::for /l %%a in (1,1,15) do shutdown /r /t 0
shutdown /r /t 0
ping 127.1>nul
shutdown /r /t 0
ping 127.1>nul
shutdown /r /t 0
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉