Asked by:
Script for setting up the Vista or Win-7 BCD to boot WinPE from hard disk files. No partitioning required.

General discussion
-
I find it very convenient to boot WinPE from the HD instead of finding the thumb-drive or CD to boot from. So, I've worked up this cmd.exe script to assist me with setting up WinPE to boot from hard disk files. It is fairly robust, works for me on many different machines, so thought it would be good to share it. Use it, dissect it, borrow parts for other tasks - shucks. Have a ball.
@echo off rem Note: This script for WinPE for Windows Vista sp1 rem rem For adding entries into the BCD store to set up WinPE to load from a HDD location. rem The boot files are copied from a working WinPE bootable CDrom disk. rem The point is to be able to boot WinPE from the HDD without needing to find the rem bootable CD disk. rem rem For safety this script exports the system BCD store to a temporary store rem then edits the temporary store. After success, the temporary store is rem imported into the system BCD store. rem rem As scripted here, the WinPE boot files must exist on this drive and path: rem drive D: ( variable WPDrv ) rem folder \wpeboot ( variable WPPth ) rem The Drive and Path to the WinPE boot files can be changed by rem modifying two cmd.exe set statements (below) before executing this script. rem To change the location later, run the 'delete' script, move the files, rem modify this script and add the settings again. rem rem Typically there will be two WinPE boot files rem boot.Wim ( variable WimNm ) rem boot.Sdi ( variable SdiNm ) rem You will copy them manually from the working Winpe boot cd rom disk rem \sources\boot.wim and \boot\boot.sdi locations into the D:\wpeboot folder. rem Assuming that the WinPE boot CD was created normally the .wim rem file is named boot.wim and the .sdi file is named boot.sdi rem If you rename them you must fix the set statements (below) appropriately. rem rem This script creates the osloader entry and the device options entry for it, rem obtaining the randomly created GUIDs (variables guid1 and guid2). rem This script also creates 'DelWinpe.cmd' command file for you to use if rem required to remove those two entries from the BCD store. This also gives rem you a permanent record of the two ramdomly generated GUIDs. echo Exporting the system BCD store to BcdTemp bcdedit /export BcdTemp if errorlevel 1 echo Error - we need to have admin privileges. if errorlevel 1 goto Endit rem Set the name of the Winpe .wim file set WimNm=boot.wim rem Set the name of the WinPE .sdi file set SdiNm=boot.sdi rem Set the drive where the two WinPE boot files are located ( x: with no \ ) set WPDrv=D: rem Set the folder path to the WinPE boot files ( no drive letter, no trailing \ ) set WPPth=\wpeboot rem Description that shows up in the boot menu set WPDes="WinPE 6.0.6001 (Vista sp1)" rem Create the osloader and device options entries in the bcd store. rem Get the randomly created GUID numbers that uniquely identify our two entries. For /F "tokens=3 delims= " %%1 in ('bcdedit.exe /store BcdTemp /create /application OSLOADER /d %WPDes%') do set guid1=%%1 echo Osloader entry id is %guid1% For /F "tokens=3 delims= " %%1 in ('bcdedit.exe /store BcdTemp /create /device /d %WPDes%') do set guid2=%%1 echo Device options entry id is %guid2% echo Setting items in the osloader entry bcdedit /store BcdTemp /set %guid1% device ramdisk=[%WPDrv%]%WPPth%\%WimNm%,%guid2% bcdedit /store BcdTemp /set %guid1% osdevice ramdisk=[%WPDrv%]%WPPth%\%WimNm%,%guid2% bcdedit /store BcdTemp /set %guid1% path \windows\system32\boot\winload.exe bcdedit /store BcdTemp /set %guid1% locale en-US bcdedit /store BcdTemp /set %guid1% inherit {bootloadersettings} bcdedit /store BcdTemp /set %guid1% systemroot \windows bcdedit /store BcdTemp /set %guid1% detecthal Yes bcdedit /store BcdTemp /set %guid1% winpe Yes bcdedit /store BcdTemp /set %guid1% ems No echo Setting items in the device options entry bcdedit /store BcdTemp /set %guid2% ramdisksdidevice partition=%WPDrv% bcdedit /store BcdTemp /set %guid2% ramdisksdipath %WPPth%\%SdiNm% echo Setting bootmgr to include the WinPE entry in the boot display list bcdedit /store BcdTemp /set {bootmgr} displayorder %guid1% /addlast rem Create an undo cmd file to delete the entries directly from the system bcd store. echo Creating the DelWinpe.cmd undo command file echo bcdedit /delete %guid1% >>DelWinpe.cmd echo bcdedit /delete %guid2% >>DelWinpe.cmd echo Display bootmgr and the two new entries bcdedit /store BcdTemp /enum {bootmgr} bcdedit /store BcdTemp /enum %guid1% bcdedit /store BcdTemp /enum %guid2% echo. If errorlevel 1 echo Error - something went awry. Not importing the temporary store. If errorlevel 1 goto Endit echo Ready to import the temporary store into bcd system store... pause echo Importing BcdTemp into the system BCD store. bcdedit /import BcdTemp :Endit set guid1= set guid2= set WpDrv= set WPPth= set WimNm= set SdiNm= set WPDes= echo done
Friday, July 31, 2009 11:00 PM
All replies
-
Hi Bit fiddler,
I could really do with your help. I have been working on this for weeks and it looks like you seem to know what your doing in order for you to have written a script to automate the task. :)
So, straight to the point...
I have a system with XP already installed. I have a "Bootable Windows PE RAM Media" (A bootable WinPE 3.0 enviroment aka boot.wim, and i also have it as boot.iso).
I am simply trying to figure out a way of making a change (or a few changes) to switch the system so that when it is restarted it is booted into the WinPE (no dual boot options). Then making another change (or a few), the system will be back to normal when it is next restarted.
I've looked the 2 most popular examples on lots of boards,
1) Copy a win2003-sp2 setupldr.bin and rename it to ntldr, and copy the ntdetect.com files along with a little winnt.sif file and my winpe.iso to the c: drive
2) Using bcdedit, change the bootsector loader information.
Results:
1) It boots the new loader, following the instructions in the winnt.sif to virtually load the winpe.iso but stops at an error "File \$WIN_NT$.~BT\biosinfo.inf could not be loaded..." (this is weird, I've searched through the files and this requied file is nowhere to be found).
2) The has not changed affect and still shows the results of the attempt above. Also, I wouldnt know how to reverse this step in order to go back to having the normal boot sequence.
Could you shed any light at all on this please?
Thanks in advanced.
Neil
Sunday, July 11, 2010 2:54 AM -
i have a problem, for some reason i deleted my Bootable Recovery Partition, and i dont know how to recover it. please i need help, sory bad englishMonday, August 9, 2010 4:08 PM
-
Bitfiddler,
I recently cannot enter the recovery environment after rebooting and pressing F8. When I select "repair my computer." it just boots to my desktop normally, instead of entering recovery mode. I am including my bcdedit /enum all below. Could you please take a look and see if you can identify what the problem might be?
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.C:\Windows\system32>bcdedit /enum all
Windows Boot Manager
--------------------
identifier {bootmgr}
device partition=\Device\HarddiskVolume2
description Windows Boot Manager
locale en-us
inherit {globalsettings}
default {current}
resumeobject {2d1020e0-9b28-11df-a002-a4badbfacbd8}
displayorder {current}
toolsdisplayorder {memdiag}
timeout 30Windows Boot Loader
-------------------
identifier {current}
device partition=C:
path \Windows\system32\winload.exe
description Windows 7
locale en-us
inherit {bootloadersettings}
recoverysequence {2d1020e2-9b28-11df-a002-a4badbfacbd8}
recoveryenabled Yes
osdevice partition=C:
systemroot \Windows
resumeobject {2d1020e0-9b28-11df-a002-a4badbfacbd8}
nx OptIn
bootstatuspolicy IgnoreShutdownFailuresWindows Boot Loader
-------------------
identifier {7a17869d-c7c3-11df-92d7-a4badbfacbd8}
device ramdisk=[\Device\HarddiskVolume2]\Recovery\WindowsRE\Win
re.wim,{7a17869e-c7c3-11df-92d7-a4badbfacbd8}
path \windows\system32\winload.exe
description Windows Recovery Environment
inherit {bootloadersettings}
osdevice ramdisk=[\Device\HarddiskVolume2]\Recovery\WindowsRE\Win
re.wim,{7a17869e-c7c3-11df-92d7-a4badbfacbd8}
systemroot \windows
nx OptIn
winpe YesResume from Hibernate
---------------------
identifier {2d1020e0-9b28-11df-a002-a4badbfacbd8}
device partition=C:
path \Windows\system32\winresume.exe
description Windows Resume Application
locale en-US
inherit {resumeloadersettings}
filedevice partition=C:
filepath \hiberfil.sys
debugoptionenabled NoWindows Memory Tester
---------------------
identifier {memdiag}
device partition=\Device\HarddiskVolume2
path \boot\memtest.exe
description Windows Memory Diagnostic
locale en-US
inherit {globalsettings}
badmemoryaccess YesEMS Settings
------------
identifier {emssettings}
bootems YesDebugger Settings
-----------------
identifier {dbgsettings}
debugtype Serial
debugport 1
baudrate 115200RAM Defects
-----------
identifier {badmemory}Global Settings
---------------
identifier {globalsettings}
inherit {dbgsettings}
{emssettings}
{badmemory}Boot Loader Settings
--------------------
identifier {bootloadersettings}
inherit {globalsettings}
{hypervisorsettings}Hypervisor Settings
-------------------
identifier {hypervisorsettings}
hypervisordebugtype Serial
hypervisordebugport 1
hypervisorbaudrate 115200Resume Loader Settings
----------------------
identifier {resumeloadersettings}
inherit {globalsettings}Device options
--------------
identifier {7a17869e-c7c3-11df-92d7-a4badbfacbd8}
description Ramdisk Options
ramdisksdidevice partition=\Device\HarddiskVolume2
ramdisksdipath \Recovery\WindowsRE\boot.sdiC:\Windows\system32>
Sunday, October 10, 2010 1:14 PM