@echo off
title ◇Fool Backup and Restore System 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% o'clock %tm2% minutes by QQ25969805 ┋
echo.┋ ┋
echo ┋ 〖1. Restore System〗 ┋
echo ┋ 〖2. Backup System〗 ┋
echo ┋ 〖3. Optimization Settings〗 ┋
echo.┋ ┋
echo.┋ ╔┉┉┉┉┉┉┉┉┉┉┉┋
echo.┋ ┋Z. Exit Program┋M. Program Introduction┋
echo.╚┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉╝
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
echo ┏━━━━━━━━━━━━━┓
echo ┃Please enter the number you want and press Enter: ┃
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 │Press any key to start restoring the system... │
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 │Checking available disk space...│
echo └──────────┘
set nofile=1
set driver=f
goto check
:nextchecknf
set driver=e
goto check
:nextcheckne
set driver=d
goto check
:nextchecknd
echo ┌────────┐
echo │Insufficient disk space...│
echo └────────┘
exit
goto :eof
: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 │Starting backup to %driver% disk│
echo └──────────┘
set image=fb
goto function
:oke
echo ┌──────────┐
echo │Starting backup to %driver% disk│
echo └──────────┘
set image=eb
goto function
:okd
echo ┌──────────┐
echo │Starting backup to %driver% disk│
echo └──────────┘
set image=db
goto function
exit
goto :eof
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:check
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "Available bytes"') do set c=%%c
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "Available bytes"') do set d=%%d
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "Available bytes"') do set e=%%e
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "Available bytes"') do set f=%%f
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "Available bytes"') do set g=%%g
for /f "tokens=1-10 delims=, " %%a in ('dir %driver%: ^| find "Available bytes"') do set h=%%h
echo %d% | find "bytes" >nul
if %ERRORLEVEL% neq 0 goto nexte
set space=%c%
:nexte
echo %e% | find "bytes" >nul
if %ERRORLEVEL% neq 0 goto nextf
set space=%c%%d%
set /a space=%space%/1024/1024
:nextf
echo %f% | find "bytes" >nul
if %ERRORLEVEL% neq 0 goto nextg
set space=%c%%d%%e%
set /a space=%space%/1024/1024
:nextg
echo %g% | find "bytes" >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 "bytes" >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 Please contact QQ25969805
cls
echo ┌─────┐
echo │load...ok`│
echo └─────┘
echo ┌───────────────────────────┐
echo │The system will automatically restart in 10 seconds. If it doesn't restart automatically, please restart manually│
echo └───────────────────────────┘
%SystemRoot%\system32\shutdown /r /t 10 /c "Backing up C drive to %driver%:\ghost\ghost"
echo ┌───────────────┐
echo │Press Q to cancel restart. Press any key to restart immediately│
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
:nextsf
set driver=e
goto checkss
:nextse
set driver=d
goto checkss
:nextsd
echo ┌────────────────┐
echo │No (f.e.d):\ghost\ghost file found│
echo └────────────────┘
echo ┌───────────┐
echo │Starting to search for local gho files...│
echo └───────────┘
ping 127.1 /n 2 >nul
cls
echo ┌───────────┐
echo │Starting to search for local gho files...│
echo └───────────┘
echo ┌─────────────┐
echo │This may take a few minutes... │
echo └─────────────┘
echo ┌─────┐
echo │Please wait... │
echo └─────┘
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
set driver=f
goto chkgho
:chkghof
set driver=e
goto chkgho
:chkghoe
set driver=d
goto chkgho
:chkghod
echo ┌─────────┐
echo │No gho backup file found!│
echo └─────────┘
ping 127.1>nul
goto start
exit
goto :eof
:chkgho
echo ┌───────┐
echo │Searching %driver% disk...│
echo └───────┘
for /f "tokens=1 delims=," %%a in ('dir %driver%:\*.gho /s ^| find /i "directory of"') do set p=%%a
set /a ytest=%p%+1
if %ytest%==1 goto chkgho%driver%
cls
echo ┌───────────┐
echo │Starting to search for local gho files...│
echo └───────────┘
echo ┌─────────────┐
echo │This may take a few minutes... │
echo └─────────────┘
echo ┌─────┐
echo │Please wait... │
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 ┋The "%ghopath%" has been transferred to "%driver%:\ghost\ghost"!
echo ╚┉┉┉
ping 127.1>nul
echo ┌────────┐
echo │Starting to restore the system... │
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 │The system will automatically restart in 10 seconds. If it doesn't restart automatically, please restart manually│
echo └───────────────────────────┘
%SystemRoot%\system32\shutdown /r /t 10 /c "Restoring %driver%:\ghost\ghost to C drive"
echo ┌───────────────┐
echo │Press Q to cancel restart. Press any key to restart immediately│
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
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:function
attrib -a -s -h -r c:\boot.ini
ren c:\boot.ini bak.ini
attrib +a +s +h +r c:\bak.ini
attrib -a -s -h -r "%cd1%\ghost\boot.ini"
copy "%cd1%\ghost\boot.ini" c:\ /y
attrib +a +s +h "%cd1%\ghost\boot.ini"
if exist c:\grldr attrib -a -s -h -r c:\grldr
attrib -a -s -h -r "%cd1%\ghost\grldr"
copy "%cd1%\ghost\grldr" c:\ /y
attrib +a +s +h +r c:\grldr
attrib -a -s -h -r "%cd1%\ghost\boot"
xcopy "%cd1%\ghost\boot" c:\boot\ /d/r/y/e/h
attrib +a +s +h +r c:\boot
attrib +a +s +h +r "%cd1%\ghost\boot"
echo @ ECHO OFF>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo Title=Restore System Startup Settings>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo COLOR b>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo @ echo Restoring system settings. Please do not operate. It will automatically close and disappear after completion>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo attrib -a -s -h -r c:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del c:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo attrib -a -s -h -r c:\bak.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo ren c:\bak.ini boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo attrib +a +s +h +r c:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo attrib -a -s -h -r c:\grldr>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del c:\grldr>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo attrib -a -s -h -r c:\boot>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo rd c:\boot /s /q>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del d:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del e:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del f:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del g:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del h:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del i:\boot.ini>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo cls>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo @ echo Restoring system settings. Please do not operate. It will automatically close and disappear after completion>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo cd "%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup">>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo del reset.bat>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
echo exit>>"%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\reset.bat"
if /i "%choice%"=="2" goto bak1
goto resconver1
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:readme
cls
echo ┏━━━━━━━━━━━━━━┓
echo ┃ ┃
echo ┃One-key ghost under windows ┃
echo ┃ ┃
echo ┃Restore: Press Enter twice ┃
echo ┃ ┃
echo ┃Backup: Press number key 2 and then Enter ┃
echo ┃ ┃
echo ┗━━━━━━━━━━━━━━┛
echo ┌─────┐
echo │Continue(Y)...│
echo └─────┘
set choice=
set /p choice=
if /i "%choice%"=="y" goto continue
goto start
:continue
cls
echo ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
echo ┃Process: ┃
echo ┃ ┃
echo ┃When backing up: ┃
echo ┃Judge whether the f.e.d. disk has a ghost folder and the remaining space + the size of the ghost folder is greater than about 2G┃
echo ┃Then back up to the eligible disk. The order of eligible disks is f→e→d ┃
echo ┃ ┃
echo ┃When restoring the system, search for the ghost file in the ghost folder under the f→e→d drive. ┃
echo ┃If this file exists and is greater than 300m, restore this file ┃
echo ┃If there is no ghost\ghost. ┃
echo ┃Then search for .gho files under the f→e→d drive and transfer them to the root directory ghost folder and rename them to ghost. ┃
echo ┃ ┃
echo ┃The ghost file has no gho suffix. To prevent deletion by viruses such as Panda. ┃
echo ┃ ┃
echo ┃Principle:grub+bat+rar ┃
echo ┃ ┃
echo ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
echo ┌─────┐
echo │Continue(Y)...│
echo └─────┘
set choice=
set /p choice=
if /i "%choice%"=="y" goto continue1
goto start
:continue1
cls
echo ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
echo ┃About errors: ┃
echo ┃There may be errors when the drive letter is not on the first hard disk ┃
echo ┃Solution: ┃
echo ┃Assign the other partitions of the first hard disk to d or e or f. Create a ghost folder in the root directory.┃
echo ┃Delete the ghost folder in the root directory of the def hard disk with other hard disk drive letters即可 ┃
echo ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
echo ┌────┐
echo │Back... │
echo └────┘
pause>nul
goto start
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:basicset
regedit /s "%cd1%\ghost\set\s.reg"
call "%cd1%\ghost\set\s.bat"
goto start
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
::┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉┉
:en
shutdown /a
c:
cd "%ALLUSERSPROFILE%\「Start」Menu\Programs\Startup\"
reset.bat
:end
goto :eof