Jump to content

Dual Booting WinXP and PE 2 from the same hard drive (revisted)


zcaa0g

Recommended Posts

Is there a surefire way to have a WinXP and WinPE 2 dual boot on the same local drive and partition with Windows already being installed and THEN adding WinPE 2 as a boot option?

I've tried the VB script below (referenced here: http://technet.microsoft.com/en-us/magazine/cc194422.aspx) to add dual boot functionality for WinXP and WinPE 2, but it never displayed the Windows PE option, but the Boot Manager did operate correctly outside of that, but I have a bad feeling that it wouldn't work anyway since that part didn't work.

Dim WshShell, FSO 
Set WshShell = WScript.CreateObject("WScript.Shell")
Set FSO = WScript.CreateObject("Scripting.FileSystemObject")

IF FSO.FolderExists("c:\boot") then
Msgbox "The ""c:\boot"" folder already exists. Please delete it (to verify you want it overwritten)."
END IF

WSHShell.run "bcdedit /createstore", 0, TRUE
WSHShell.run "bcdedit /create {ramdiskoptions} /d ""Boot Windows PE""", 0, TRUE
WSHShell.run "bcdedit /set {ramdiskoptions} ramdisksdidevice partition=c:", 0, TRUE
WSHShell.run "bcdedit /set {ramdiskoptions} ramdisksdipath \boot\boot.sdi", 0, TRUE
Set getGUID = WshShell.Exec("bcdedit -create /d ""Windows PE"" /application OSLOADER")
Do While getGUID.Status = 0
WScript.Sleep 100
Loop

'Fun little set of code to grep out the GUID
strGUID = getGUID.StdOut.ReadAll
arr1GUID = Split(strGUID, "{")
arr2GUID = Split("{"&arr1GUID(1), "}")
strGUID = arr2GUID(0)&"}"

WSHShell.run "bcdedit /set "&strGUID&" device ramdisk=[c:]\boot\boot.wim,{ramdiskoptions}", 0, TRUE
WSHShell.run "bcdedit /set "&strGUID&" path \windows\system32\winload.exe", 0, TRUE
WSHShell.run "bcdedit /set "&strGUID&" osdevice ramdisk=[c:]\boot\boot.wim,{ramdiskoptions}", 0, TRUE
WSHShell.run "bcdedit /set "&strGUID&" systemroot \windows", 0, TRUE
WSHShell.run "bcdedit /set "&strGUID&" winpe yes", 0, TRUE
WSHShell.run "bcdedit /set "&strGUID&" detecthal yes", 0, TRUE

WSHShell.run "Bcdedit /create {bootmgr} /d ""Boot Manager""", 0, TRUE
WSHShell.run "Bcdedit /set {bootmgr} device boot", 0, TRUE
'Create the entry to boot Windows XP (or whatever OS's you have booting via boot.ini
WSHShell.run "bcdedit /create {ntldr} /d ""Windows XP""", 0, TRUE
WSHShell.run "bcdedit /set {ntldr} device partition=C:", 0, TRUE
WSHShell.run "bcdedit /set {ntldr} path \ntldr", 0, TRUE
WSHShell.run "bcdedit /displayorder {ntldr} /addfirst", 0, TRUE

'Without these files, the system won't boot
CheckFile "BOOTMGR", 1
CheckFile "BOOT\BOOT.SDI", 1
CheckFile "SOURCES\BOOT.WIM", 1

'You won't need these files unless you want additional language support at boot time.
CheckFile "BOOT\FONTS\CHS_BOOT.TTF", 0
CheckFile "BOOT\FONTS\CHT_BOOT.TTF", 0
CheckFile "BOOT\FONTS\JPN_BOOT.TTF", 0
CheckFile "BOOT\FONTS\KOR_BOOT.TTF", 0
CheckFile "BOOT\FONTS\WGL4_BOOT.TTF", 0

Msgbox "Your system is now set up to boot Windows PE 2.0 as well as your previous operating systems."

'Function to check for and copy the necessary files for BOOTMGR functionality
FUNCTION CheckFile(FilePath,bCrit)
IF NOT FSO.FileExists(FilePath) then
If bCrit = 1 THEN
IF FilePath = "BOOTMGR" THEN
Msgbox "Script could not find the file "&FilePath&", which is needed to set up the system to boot to Windows PE 2.0."&vbcrlf&"Please place it in the same directory as this script and re-start the script."
ELSE
Msgbox "Script could not find the file "&FilePath&", which is needed to set up the \boot directory."&vbcrlf&"Please place it in a directory named ""boot"" (or ""sources"" for the boot.wim file to be copied) in the same directory as this script and re-start the script."
END IF
END IF
ELSE
IF FilePath = "SOURCES\BOOT.WIM" THEN
FSO.CopyFile FilePath, "C:\BOOT\BOOT.WIM"
ELSE
IF NOT FSO.FolderExists("c:\boot\fonts") THEN
FSO.CreateFolder("c:\boot\fonts")
END IF
FSO.CopyFile FilePath, "C:\"&FilePath
END IF
END IF
END FUNCTION

I also tried the batch routine from WreX below and it will show the WinPE option in the boot menu and XP and the receovery console work fine, however, it gets the Status:0xc000000f error message that "The Boot selection failed because a required device is inaccessible.". And I assume I need to apply the WinPE.wim to a certain path, but I am not sure of where.

xcopy D:\BOOT\*.* /e /f /y C:\BOOT\
copy D:\BOOTMGR C:\
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:]\WINPE\WINPE.WIM,{ramdiskoptions}
bcdedit -set %guid% path \WINDOWS\SYSTEM32\BOOT\WINLOAD.EXE
bcdedit -set %guid% osdevice ramdisk=[C:]\WINPE\WINPE.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 "Windows XP Professional"
bcdedit -set {ntldr} device boot
bcdedit -set {ntldr} path \ntldr
bcdedit -displayorder {ntldr} -addfirst
bcdedit -default {ntldr}
bcdedit -timeout 5
bootsect /nt60 C:

If anyone has any suggestions, it would be greatly appreciated! Thanks.

Edited by zcaa0g
Link to comment
Share on other sites


Hmmm, same problem. The boot manager shows up correctly after running this and while Windows XP boots up fine and the recovery console boots up fine, the WinPE selection receives the following error message:

Windows failed to start. A recent hardware or software change might be the cause. To fix the problem:

1. Insert your Windows installation disc and restart your computer.

2. Choose your language settings, and then click "Next."

3. Click "Repair your computer."

If you do not have this disc, contact your system administrator or computer manufacturer for assistance.

Status: 0xc000000f

Info: The boot selection failed because a required device is inaccessible.

My process is I throw on a clean Windows XP image that has the Windows XP and Recovery Console boot options and no 'Boot Manager' yet. Then I boot from WinPE 2 and run the aforementioned batch file process in this thread and all that runs without error. Then once I reboot, the 'Boot Manager' shows up with all three of the entries, but the WinPE option fails with the aforementioned error.

Any ideas anyone?

Link to comment
Share on other sites

I've found that after SysPrep runs it somehow screws up PE boot entries in the BCD. When you're in your problem scenario, run "bcdedit" and look at the output. You're probably missing some key info for the PE option. There's probably a better solution, but I get around this by re-running the commands that set all the ramdisk options and %guid% stuff from a batch file on first boot.

Another thread mentioned that if they put the XP boot files on the PE partition they didn't have this problem, but I boot PE from C: and XP from D:, so I already have them together on C:.

Link to comment
Share on other sites

I won't be much help with the "ramdisk" option as I extract the PE wim on it's own partition.

Is that an option you can try?

If so, try this:

@ECHO OFF
SET CD=**This should be your optical drive with the WinPE disk**
SET RECVY=**This should be the drive designated for WinPE**
SET REGUID=**572BCD55-FFA7-11D9-AAE0-0007E994107D**
BOOTSECT.EXE /NT60 %RECVY%
IMAGEX /APPLY BOOT.WIM 1 %RECVY% **This applies the image to the parition you have selected for WinPE, so the ramboot option isn't required**
MD %RECVY%\BOOT\
XCOPY %CD%\BOOT\*.* /E /F %RECVY%\BOOT\
COPY %CD%\BOOTMGR %RECVY%
%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 BOOT
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 "Windows Recovery" -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 -DISPLAYORDER {NTLDR} {%REGUID%}
BCDEDIT -STORE %RECVY%\BOOT\BCD -TIMEOUT 0
WPEUTIL REBOOT

I would initially have the REGUID dynamically created, but I found this REGUID on one of the MS sites and it hasn't given me a problem yet.

Also, when ever I add a WinPE partition to a PC, I always add it to the first partition on the disk. I've never tried adding it to the last partition.

*Make sure the WinPE partition is marked active.

*Make sure you move the WinXP bootfiles (ntldr, ntdetect.com, boot.ini) to the WinPE partition

Wrex - I seem to have fixed the problem with sysprep screwing up the BCD, by making the WinPE partition hidden from WinXP.

Edited by TheReasonIFail
Link to comment
Share on other sites

Thanks for both of your responses. I am looking to deploy this in the future to about 1500 workstations, so I have to make sure it's flawless, so I will have to run through different scenarios. A second partition isn't too big of a deal as I can always hide and lock that from access within the Windows environment anyway, so the users can't mess anything up. I may go that route. Thanks again.

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...