Adding a Refresh Option to the Boot Menu

email me

This adds a Refresh Computer boot menu option to point to a recovery partition (e: in my case).

This boot option will launch your customized boot.wim, which will load the WinPE interface.
You can customize exactly what you want to happen once WinPE loads by editing the startnet.cmd in the boot.wim (c:\windows\system32\startnet.cmd).

You could refresh your system partition by storing an image.wim located on your recovery partition:

diskpart /s PathToRecoveryPartition\disk.txt (your partitioning sequence goes in here)

PathToRecoveryPartition\imagex.exe /apply PathToRecoveryPartition\image.wim 1 c: (c: or other drive will be your windows partition)

 

So, if you want to fully automate refreshing a computer from the boot menu:

Step 1 – Build an image.wim that is automated (this will be your customized windows image)

Step 2 – Edit the boot.wim startnet.net with diskpart and imagex command lines (basically the
WinPE.wim with added packages for scripting, hta, vbscript, etc.)

Step 3 – Partition drive with 4 partitions: system reserved, system, recovery, data (in that order)

Step 4 – Copy recovery files to recovery partition

Step 5 – Run the script below in WinPE

Step 6 – Select Recovery Option from the boot menu

 

Script

@echo off
color 0a
title Administrative Boot Loader

setlocal

:: Use the following set of commands to create a ramdiskoptions
:: object in the BCD store. The string "{ramdiskoptions}" is the
:: well-known name for the object's GUID.

set bcdedit=%systemroot%\system32\bcdedit.exe
set bcdstore=c:\boot\bcd

rem WDS
bcdedit /create {ramdiskoptions} /d "Refresh Your Computer"
bcdedit /set {ramdiskoptions} ramdisksdidevice partition=c:
bcdedit /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi

rem Create a new boot entry.
bcdedit -create /d "Refresh Your Computer" /application OSLOADER
for /f "tokens=3" %%A in ('%bcdedit% -create /d "Refresh Your Computer" /application OSLOADER') do set guid1=%%A
echo The GUID is %guid1%

%bcdedit% /set %guid1% device ramdisk=[e:]\boot.wim,{ramdiskoptions}
%bcdedit% /set %guid1% path \windows\system32\boot\winload.exe
%bcdedit% /set %guid1% osdevice ramdisk=[e:]\boot.wim,{ramdiskoptions}
%bcdedit% /set %guid1% systemroot \Windows
%bcdedit% /set %guid1% winpe yes
%bcdedit% /set %guid1% detecthal yes
%bcdedit% /displayorder %guid1% /addlast
rem this sets boot to be default
rem %bcdedit% /default %guid1%

endlocal

pause
exit /b 0