Hi, Hoping someone can help.
I am trying to create a command line program that adds a WinPE boot option when the user runs a program called "Recovery", the object being that the user can use a bespoke image to recover the system .. but it is only available by running this program.
I have my hard drive set up with a 300MB system partition, a 16MB Microsoft reserved partition, a Recovery Partition (called SMARTBOX that has WinPE on it ) and an Micro SD drive that contains the bespoke image.
My Recovery program (in part) is as follows;
Everything completes ok with no errors, however on re-boot I have no boot options menu, it just boots directly into windows 10 as if no new boot option had been added.
Any help appreciated.
I am trying to create a command line program that adds a WinPE boot option when the user runs a program called "Recovery", the object being that the user can use a bespoke image to recover the system .. but it is only available by running this program.
I have my hard drive set up with a 300MB system partition, a 16MB Microsoft reserved partition, a Recovery Partition (called SMARTBOX that has WinPE on it ) and an Micro SD drive that contains the bespoke image.
My Recovery program (in part) is as follows;
Code:
REM ** FIND IS SD CARD IS INSERTED
WMIC DISKDRIVE GET CAPTION,NAME > %DES%\DD.TXT
FOR /F "TOKENS=1 DELIMS=" %%i IN ('FIND /I "CARD" "%DES%\DD.TXT"') DO SET SD=%%i
DEL %DES%\DD.TXT /Q
IF DEFINED SD (ECHO.) ELSE (GOTO ER1)
REM ** FIND 'SMARTBOX' PARTITION
ECHO SEL DISK 0 > %DES%\DP1.TXT
ECHO LIST VOL >> %DES%\DP1.TXT
DISKPART /S %DES%\DP1.TXT > %DES%\RECOVERY.TXT
DEL %DES%\DP1.TXT
FOR /F "TOKENS=1 DELIMS=" %%j IN ('FIND /I "SMARTBOX" "%DES%\RECOVERY.TXT"') DO SET RECOVER=%%j
IF DEFINED RECOVER (ECHO.) ELSE (GOTO ADDRECOVER)
FOR /F "TOKENS=1,2 DELIMS= " %%a IN ("%RECOVER%") DO SET /A WINPE=%%b
FIND ** FIND SYSTEM PARTITION
FOR /F "TOKENS=1 DELIMS=" %%k IN ('FIND /I "SYSTEM" "%DES%\RECOVERY.TXT"') DO SET SYS=%%k
FOR /F "TOKENS=1,2 DELIMS= " %%a IN ("%SYS%") DO SET /A SYSTEM=%%b
DEL %DES%\RECOVERY.TXT
REM ** ASSIGN DRIVE LETTERS TO SMARTBOX AND SYSTEM PARTITIONS
ECHO SEL DISK 0 > %DES%\DP1.TXT
ECHO SEL VOL %WINPE% >> %DES%\DP1.TXT
ECHO ASSIGN LETTER=Y: >> %DES%\DP1.TXT
ECHO SEL VOL %SYSTEM% >> %DES%\DP1.TXT
ECHO ASSIGN LETTER=S: >> %DES%\DP1.TXT
DISKPART /S %DES%\DP1.TXT
DEL %DES%\DP1.TXT
REM ** ADD WINPE BOOT TO BOOT MENU
set BCDEDIT=%SYSTEMROOT%\system32\bcdedit.exe
set BCDSTORE=S:\Boot\BCD
for /f "tokens=3" %%A in ('%BCDEDIT% /store %BCDSTORE% /create /application osloader') do set guid=%%A
%BCDEDIT% /store %BCDSTORE% /set %guid% systemroot \Windows
%BCDEDIT% /store %BCDSTORE% /set %guid% detecthal Yes
%BCDEDIT% /store %BCDSTORE% /set %guid% winpe Yes
%BCDEDIT% /store %BCDSTORE% /set %guid% osdevice ramdisk=[boot]\sources\boot.wim,{ramdiskoptions}
%BCDEDIT% /store %BCDSTORE% /set %guid% device ramdisk=[boot]\sources\boot.wim,{ramdiskoptions}
%BCDEDIT% /store %BCDSTORE% /set %guid% description "Smartbox Recovery"
%BCDEDIT% /store %BCDSTORE% /displayorder %guid% /addfirst
c:\windows\system32\shutdown.exe /r /t 0
Everything completes ok with no errors, however on re-boot I have no boot options menu, it just boots directly into windows 10 as if no new boot option had been added.
Any help appreciated.