Imagex introduction:
Microsoft's official image packaging tool is file-based and can find suitable hardware through files, unlike sector-based GHOST, which has a low compression rate and is full of problems after restoration.
The install.wim in the sources folder of the original Vista/windows 7 installation disk directory is a mirror based on imagex.
It was actually measured that the backup of a 15G system disk took 20 minutes (standard compression rate) and the volume was about 4G.
The restore takes about 10 minutes.
Since imagex is a command line operation, many people are confused. So I came up with the idea of using my three-legged cat's batch processing skills to do a simple batch process to achieve a simple system backup/restore.
There are many flaws, and I hope experts can point them out.
illustrate:
This file can only be run in the PE environment (imagex limitation)
The best solution for Windows 7 systems is to restart and press F8, select "Repair Computer" and next select "Command Prompt"
Just switch to the directory where bat is located and run abc.bat.
Other systems can also be used, but a CD or USB flash drive is required to boot into PE mode.
One of the big problems is that the drive letters will be messed up and the D drive will not necessarily become which drive.
So I have a lot of questions and I hope experts can give me advice! The following is the code:
@echo off
title System backup program produced by Jiang Zhikun
echo.
:menu
colorce
mode con:cols=90 lines=18
if exist d:imageximagex.exe goto act
echo ===================================
The echo program will copy the imagex program to the D drive
echo Press any key to continue
echo ===================================
pause->nul
xcopy %cd%imagex d:imagex /e /i
goto act
:act
cls
echo ===================================
echo This program needs to be run in a PE environment
The method to enter PE in echo win7 is:
echo Restart and press F8
echo Select the first item "Repair your computer"
After entering echo, select "Command Prompt"
Echo automatic backup will default to system disk C and target disk D
Echo automatic restore will format the C drive and restore the files in the D drive
echo if data is lost
echo bans pursuit across provinces
echo Welcome to communicate via email: [email protected]
echo ===================================
pause->nul
goto chose
:chose
cls
echo Please select the operation to be performed and press Enter to confirm.
echo 1. Make a backup
echo 2. Restore system
echo 3. Delete backup
echo 4. Exit the program
echo 5. Automatic backup
echo 6. Automatic restoration
echo.
set cho=
set /p cho=input:
if /i "%cho%"=="1" goto 1
if /i "%cho%"=="2" goto 2
if /i "%cho%"=="3" goto 3
if /i "%cho%"=="4" goto 4
if /i "%cho%"=="5" goto 5
if /i "%cho%"=="6" goto 6
cls
echo Select invalid and re-enter
pause->nul
goto chose
:1
cls
set /p xtpanfu=Please enter the partition drive letter to be backed up:
if not "%xtpanfu%"=="" set xtpanfu=%xtpanfu:~0,1%
set /p panfu=Please enter the backup file target drive letter:
if not "%panfu%"=="" set panfu=%panfu:~0,1%
if exist %panfu%:systembackup.wim echo will delete the previous backup file&pause&&del %panfu%:systembackup.wim
d:
cd imagex
imagex /capture %xtpanfu%: %panfu%:systembackup.wim "backup"
echo ====================================
echo backup completed! Back up the system to the %panfu% disk
The echo file name is systembackup.wim
echo Please restart your computer
echo ====================================
set /ppanfu=
set /p xtpanfu=
goto chose
:2
cls
set /p panfu=Please enter the drive letter where the backup file is located:
if not "%panfu%"=="" set panfu=%panfu:~0,1%
set /p xtpanfu=Please enter the system drive letter:
if not "%xtpanfu%"=="" set xtpanfu=%xtpanfu:~0,1%
echo =====================================
echo Confirm to format the %xtpanfu% disk
echo and use the image file of %panfu% disk to restore?
echo Enter Y to continue
echo Enter N to return to the menu
echo =====================================
set /p sf=
if /i "%sf%"=="Y" goto Y
if /i "%sf%"=="N" goto chose
cls
echo Invalid input will return to the menu
pause
goto chose
:Y
format %xtpanfu%: /fs:ntfs /q /y
d:
cd imagex
imagex /apply %panfu%:systembackup.wim 1 %xtpanfu%:
bcdboot %xtpanfu%:windows /s %xtpanfu%:
echo ====================================
echo System restore completed! Please restart your computer
echo ====================================
set /ppanfu=
set /p xtpanfu=
set /p sf=
goto chose
:3
cls
set /p panfu=Please enter the drive letter where the backup file is located:
if not "%panfu%"=="" set panfu=%panfu:~0,1%
if not exist %panfu%:systembackup.wim echo cannot find the file, press any key to return to the menu&pause ->nul&&cls&&goto chose
del %panfu%:systembackup.wim /f
echo backup deleted successfully!
goto chose
:4
exit
:5
cls
echo ====================================
echo This operation will backup C drive to D drive
echo Press any key to continue
echo ====================================
pause->nul
d:
cd imagex
imagex /capture c: d:systembackup.wim "backup"
echo ====================================
echo System backup completed! Please restart your computer!
echo ====================================
pause->nul
goto chose
:6
cls
echo ====================================
echo This operation will format the C drive! Press any key to confirm
echo ====================================
pause->nul
format c: /q /y
d:
cd imagex
imagex /apply d:systembackup.wim 1 c:
bcdboot c:windows /sc:
echo ====================================
echo system restore completed
echo Please restart your computer
echo ====================================
pause->nul
goto chose
Copy code Note: There is imagex.exe in the current directory