Jump to content

Adding XP to BCD


TheReasonIFail

Recommended Posts

OK,

I'm trying to setup BCD to show WinPE and WinXP. Things aren't working too well.

Here is the script I'm currently using.

To me it seems that when I add the entry for XP, it overwrites the PE entry.

Any and all help is appreciated.

@ECHO OFF
SET CD=D:
SET PHD=W:
SET XHD=C:
DISKPART -S DEFAULTPART.TXT
imagex /apply %CD%\sources\boot.wim 1 %PHD%
imagex /apply winxp.wim 1 %XHD%
xcopy %CD%\boot\*.* /e /f %PHD%\boot\
copy %CD%\bootmgr %PHD%
del %PHD%\boot\bcd
Bcdedit -createstore %PHD%\boot\BCD
Bcdedit -store %PHD%\boot\BCD -create {bootmgr} /d "Boot Manager"
Bcdedit -store %PHD%\boot\BCD -set {bootmgr} device boot
Bcdedit -store %PHD%\boot\BCD -create /d "WINPE" -application osloader
notepad winpeinst.bat
Bcdedit -store %PHD%\boot\BCD -set <GUID> osdevice partition=%PHD%
Bcdedit -store %PHD%\boot\BCD -set <GUID> device partition=%PHD%
Bcdedit -store %PHD%\boot\BCD -set <GUID> path \windows\system32\boot\winload.exe
Bcdedit -store %PHD%\boot\BCD -set <GUID> systemroot \windows
Bcdedit -store %PHD%\boot\BCD -set <GUID> winpe yes
Bcdedit -store %PHD%\boot\BCD -set <GUID> detecthal yes
Bcdedit -store %PHD%\boot\BCD -CREATE {LEGACY} /D "Windows XP"
Bcdedit -store %PHD%\boot\BCD -SET {LEGACY} DEVICE BOOT
Bcdedit -store %PHD%\boot\BCD -SET {LEGACY} PATH \NTLDR
Bcdedit -store %PHD%\boot\BCD -DISPLAYORDER {LEGACY} -ADDLAST

Edited by TheReasonIFail
Link to comment
Share on other sites


All right, after some playing I've edited to:

@ECHO OFF
SET CD=D:
SET PHD=W:
SET XHD=C:
DISKPART -S DEFAULTPART.TXT
imagex /apply %CD%\sources\boot.wim 1 %PHD%
imagex /apply winxp.wim 1 %XHD%
xcopy %CD%\boot\*.* /e /f %PHD%\boot\
copy %CD%\bootmgr %PHD%
del %PHD%\boot\bcd
Bcdedit -createstore %PHD%\boot\BCD
Bcdedit -store %PHD%\boot\BCD -create {bootmgr} /d "Boot Manager"
Bcdedit -store %PHD%\boot\BCD -set {bootmgr} device boot
Bcdedit -store %PHD%\boot\BCD -CREATE {NTLDR} /D "Windows XP"
Bcdedit -store %PHD%\boot\BCD -set {NTLDR} DEVICE PARTITION=%XHD%
Bcdedit -store %PHD%\boot\BCD -set {NTLDR} PATH \NTLDR
Bcdedit -store %PHD%\boot\BCD -create /D "Windows PE" -APPLICATION OSLOADER
notepad winpeinst.bat
Bcdedit -store %PHD%\boot\BCD -set <GUID> osdevice partition=%PHD%
Bcdedit -store %PHD%\boot\BCD -set <GUID> device partition=%PHD%
Bcdedit -store %PHD%\boot\BCD -set <GUID> path \windows\system32\boot\winload.exe
Bcdedit -store %PHD%\boot\BCD -set <GUID> systemroot \windows
Bcdedit -store %PHD%\boot\BCD -set <GUID> winpe yes
Bcdedit -store %PHD%\boot\BCD -set <GUID> detecthal yes
Bcdedit -store %PHD%\boot\BCD -DISPLAYORDER {NTLDR} <GUID>
Bcdedit -store %PHD%\boot\BCD -DEFAULT {NTLDR}
Bcdedit -store %PHD%\boot\BCD -TIMEOUT 2

Now I get prompted for each entry, but choosing Windows XP, gives me the following error:

File: \NTLDR

Status: 0xc000000d

Info: The selected entry could not be loaded because the application is missing or corrupt.

Edited by TheReasonIFail
Link to comment
Share on other sites

My first comment is to be sure you have the NTLDR files (NTLDR, NTDETECT.COM, and boot.ini) in the root of the primary active partition (probably C:). My second is that you have "{ntldr} device partition=" and I think it should be "{ntldr} device boot". Here's my batch file for booting a PE WIM on C: into RAM and NTLDR:

xcopy %CDROM%\BOOT\*.* /e /f /y C:\BOOT\
copy %CDROM%\BOOTMGR C:\
copy %CDROM%\SOURCES\BOOT.WIM C:\BOOT\BOOT.WIM
IF EXIST C:\BOOT\BCD DEL C:\BOOT\BCD
IF NOT EXIST C:\TEMP MD C:\TEMP
IF EXIST C:\TEMP\BCD DEL C:\TEMP\BCD
bcdedit -createstore C:\TEMP\BCD
bcdedit -store C:\TEMP\BCD -create {bootmgr} /d "Boot Manager"
bcdedit -store C:\TEMP\BCD -set {bootmgr} device boot
bcdedit -store C:\TEMP\BCD -create {ramdiskoptions} /d "WinPE"
bcdedit -import C:\TEMP\BCD
bcdedit -set {ramdiskoptions} ramdisksdidevice partition=C:
bcdedit -set {ramdiskoptions} ramdisksdipath \BOOT\BOOT.sdi
for /f "tokens=3" %%a in ('bcdedit -create /d "WinPE" -application osloader') do set guid=%%a
bcdedit -set %guid% device ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}
bcdedit -set %guid% path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXE
bcdedit -set %guid% osdevice ramdisk=[C:]\BOOT\BOOT.WIM,{ramdiskoptions}
bcdedit -set %guid% systemroot \WINDOWS
bcdedit -set %guid% winpe yes
bcdedit -set %guid% detecthal yes
bcdedit -displayorder %guid% -addlast
bcdedit -create {ntldr} /d "Microsoft Windows XP"
bcdedit -set {ntldr} device boot
bcdedit -set {ntldr} path \ntldr
bcdedit -displayorder {ntldr} -addfirst
bcdedit -default {ntldr}
bcdedit -timeout 5
bootsect /nt60 C:

Link to comment
Share on other sites

SUCCESS!!!

I've finally gotten Windows RE to work with XP and here is the script I used:

@ECHO OFF
SET CD=D:
SET PHD=E:
SET XHD=C:
SET REGUID=572bcd55-ffa7-11d9-aae0-0007e994107d
REGEDIT -S VDS.REG
DISKPART -S PREPART.TXT
BOOTSECT.EXE /NT60 All
imagex /apply winre.wim 1 %PHD%
COPY WINXP.WIM %PHD%\Sources\Recovery\*.*
IMAGEX /APPLY %PHD%\Sources\Recovery\WINXP.WIM 1 %XHD%
xcopy %CD%\boot\*.* /e /f %XHD%\boot\
copy %CD%\bootmgr %XHD%
del %XHD%\BOOT\BCD
Bcdedit -CREATESTORE %XHD%\BOOT\BCD
BCDEDIT -STORE %XHD%\BOOT\BCD -create {BOOTMGR} /d "Boot Manager"
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {BOOTMGR} DEVICE BOOT
BCDEDIT -STORE %XHD%\BOOT\BCD -CREATE {NTLDR} /D "Windows XP"
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {NTLDR} DEVICE BOOT
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {NTLDR} PATH \NTLDR
BCDEDIT -STORE %XHD%\BOOT\BCD -create {%REGUID%} /D "Windows Recovery Environment" -APPLICATION OSLOADER
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} osdevice partition=%PHD%
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} device partition=%PHD%
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} path \windows\system32\boot\winload.exe
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} systemroot \windows
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} winpe yes
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} detecthal yes
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} nx optin
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} custom:46000010 yes
BCDEDIT -STORE %XHD%\BOOT\BCD -DEFAULT {NTLDR}
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {DEFAULT} RECOVERYSEQUENCE {%REGUID%}
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {DEFAULT} RECOVERYENABLED YES
BCDEDIT -STORE %XHD%\BOOT\BCD -DISPLAYORDER {NTLDR} {%REGUID%}
REM BCDEDIT -STORE %XHD%\BOOT\BCD -TIMEOUT 2
ATTRIB +R +H +S %XHD%\BOOTMGR
ATTRIB +R +H +S %XHD%\BOOT\

and here are the command in prepart.txt

SELECT DISK 0
CLEAN
CREATE PARTITION PRIMARY SIZE=4096
ASSIGN LETTER=E:
FORMAT FS=NTFS QUICK LABEL="Windows RE"
SET ID=27
CREATE PARTITION PRIMARY
ASSIGN LETTER=C:
ACTIVE
FORMAT FS=NTFS QUICK LABEL="Windows XP"
SET ID=07

Edited by TheReasonIFail
Link to comment
Share on other sites

Well, it seems that sysprep is screwing with the BCD.

I've edited the file to be a two part install so WinPE is installed after sysprep has run on the C: drive.

I'm going to work on that today. Hopefully that will work for now.

@ECHO OFF
SET CD=D:
SET PHD=W:
SET XHD=C:
SET REGUID=572BCD55-FFA7-11D9-AAE0-0007E994107D

GOTO MENU
:MENU
ECHO.
ECHO What would you like to do?
ECHO (Press Number followed by Enter key.)
ECHO.
ECHO 1. Format and image disk with Windows XP Professional
ECHO 2. Install Windows Recovery Environment
ECHO 3. Open A43 File Manager
ECHO 4. Quit and reboot PC
ECHO.

:CHOICE
SET /P C=[1,2,3,4,5,6,7]?
IF "%C%"=="4" GOTO QUIT
IF "%C%"=="3" GOTO A43
IF "%C%"=="2" GOTO WINRE
IF "%C%"=="1" GOTO WINXP
GOTO CHOICE

:WINXP
ECHO Preparing Disk for Windows Installation
ECHO After imaging is complete, let sysprep complete before creating recovery partition
DISKPART -S DP\PREPART.TXT
REGEDIT -S VDS.REG
IMAGEX /APPLY WIM\XP_SYSPREP.WIM 1 %XHD%
START /WAIT WSCRIPT WIMHALDETECT.VBS
WPEUTIL REBOOT

:WINRE
ECHO
BOOTSECT.EXE /NT60 ALL
IMAGEX /APPLY WIM\WINRE.WIM 1 %PHD%
COPY FILES\*.* %XHD%\WINDOWS\SYSTEM32\
XCOPY %CD%\BOOT\*.* /e /f %XHD%\BOOT\
COPY %CD%\BOOTMGR %XHD%
DEL %XHD%\BOOT\BCD
BCDEDIT -CREATESTORE %XHD%\BOOT\BCD
BCDEDIT -STORE %XHD%\BOOT\BCD -create {BOOTMGR} /d "Boot Manager"
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {BOOTMGR} DEVICE BOOT
BCDEDIT -STORE %XHD%\BOOT\BCD -CREATE {NTLDR} /D "Windows XP"
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {NTLDR} DEVICE BOOT
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {NTLDR} PATH \NTLDR
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {NTLDR} LOCALE EN-US
BCDEDIT -STORE %XHD%\BOOT\BCD -create {%REGUID%} /D "Backup and Restore" -APPLICATION OSLOADER
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} OSDEVICE PARTITION=%PHD%
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} DEVICE PARTITION=%PHD%
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} path \windows\system32\boot\winload.exe
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} systemroot \windows
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} winpe yes
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} detecthal yes
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} nx optin
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} custom:46000010 yes
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {%REGUID%} LOCALE EN-US
BCDEDIT -STORE %XHD%\BOOT\BCD -DEFAULT {NTLDR}
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {DEFAULT} RECOVERYSEQUENCE {%REGUID%}
BCDEDIT -STORE %XHD%\BOOT\BCD -SET {DEFAULT} RECOVERYENABLED YES
BCDEDIT -STORE %XHD%\BOOT\BCD -DISPLAYORDER {NTLDR} {%REGUID%}
BCDEDIT -STORE %XHD%\BOOT\BCD -TIMEOUT 0
DISKPART -S DP\POST.TXT
WPEUTIL REBOOT

:A43
A43.EXE

:QUIT
WPEUTIL REBOOT

I'm using the old choice.com file to get the prompts. Is there a way to do that with some more recent "technology"?

Edited by TheReasonIFail
Link to comment
Share on other sites

  • 2 months later...

Well, I finally got it working!

I first set the WinPE partition as being active, creating the BCD and moved the XP boot files to the PE partition. Now sysprep doesn't touch the BCD and we now have a fully functional machine with PE and XP.

It never dawned on me that I should move the boot files from the XP partition to the PE partition.

Yay!

Here is what the new script looks like:

@ECHO OFF
SET CD=D:
SET RECVY=W:
SET WINXP=C:
SET REGUID=572BCD55-FFA7-11D9-AAE0-0007E994107D
REGEDIT -S VDS.REG
DISKPART -S PREPART.TXT
BOOTSECT.EXE /NT60 %RECVY%
BOOTSECT.EXE /NT52 %WINXP%
IMAGEX /APPLY BOOT.WIM 1 %RECVY%
IMAGEX /APPLY WINXPSP3.WIM 1 %WINXP%
START /WAIT WSCRIPT WIMHALDETECT.VBS
ATTRIB -R -H -S %WINXP%\NTLDR
ATTRIB -R -H -S %WINXP%\NTDETECT.COM
ATTRIB -R -H -S %WINXP%\BOOT.INI
COPY %WINXP%\NTLDR %RECVY%\
COPY %WINXP%\NTDETECT.COM %RECVY%\
COPY %WINXP%\BOOT.INI %RECVY%\
ATTRIB +R +H +S %RECVY%\NTLDR
ATTRIB +R +H +S %RECVY%\NTDETECT.COM
ATTRIB +R +H +S %RECVY%\BOOT.INI
DEL %WINXP%\NTLDR
DEL %WINXP%\NTDETECT.COM
DEL %WINXP%\BOOT.INI
MD %RECVY%\BOOT\
XCOPY %CD%\BOOT\*.* /E /F %RECVY%\BOOT\
COPY %CD%\BOOTMGR %RECVY%
DEL %RECVY%\BOOT\BCD
BCDEDIT -CREATESTORE %RECVY%\BOOT\BCD
BCDEDIT -STORE %RECVY%\BOOT\BCD -create {BOOTMGR} /d "Boot Manager"
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {BOOTMGR} DEVICE BOOT
BCDEDIT -STORE %RECVY%\BOOT\BCD -CREATE {NTLDR} /D "Windows XP"
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {NTLDR} DEVICE PARTITION=%WINXP%
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {NTLDR} PATH \ntldr
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {NTLDR} LOCALE EN-US
BCDEDIT -STORE %RECVY%\BOOT\BCD -create {%REGUID%} /D "Backup and Restore" -APPLICATION OSLOADER
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} OSDEVICE BOOT
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} DEVICE BOOT
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} PATH \windows\system32\boot\winload.exe
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} SYSTEMROOT \Windows
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} WINPE YES
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} DETECTHAL YES
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} NX OPTIN
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} CUSTOM:46000010 YES
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {%REGUID%} LOCALE EN-US
BCDEDIT -STORE %RECVY%\BOOT\BCD -DEFAULT {NTLDR}
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {DEFAULT} RECOVERYSEQUENCE {%REGUID%}
BCDEDIT -STORE %RECVY%\BOOT\BCD -SET {DEFAULT} RECOVERYENABLED YES
BCDEDIT -STORE %RECVY%\BOOT\BCD -DISPLAYORDER {NTLDR} {%REGUID%}
BCDEDIT -STORE %RECVY%\BOOT\BCD -TIMEOUT 2
WPEUTIL REBOOT

Instead of manually moving the XP bootfiles, I just added it to the script.

Edited by TheReasonIFail
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...