BCD entry for winpe only launches Preparing Automatic Repair
Asked Answered
C

1

7

I'm attempting to reboot a computer into a flash drive media containing Windows PE, but every time it only launches Preparing Automatic Repair. Here is my powershell that generates the new bcd entry:

$drive = (get-location).Drive.Name + ":"

$output = bcdedit /copy '{current}' /d "automaticabd"

$variable = "{" + $output.Split('{')[-1]
$variable = $variable.TrimEnd('.')

"Attaching $variable to device partition $drive"
bcdedit /set $variable device partition=$drive
""
"Attaching $variable to osdevice partition $drive"
bcdedit /set $variable osdevice partition=$drive
""
"Setting $variable path to EFI: \EFI\Boot\bootx64.efi"
bcdedit /set $variable path \EFI\Boot\bootx64.efi

""
"Other settings..."
bcdedit /set $variable systemroot \windows
bcdedit /set $variable winpe yes
bcdedit /set $variable  recoveryenabled No

bcdedit /bootsequence $variable

All operations are completed successfully, and it appears as though the entry is correct to my knowledge:

enter image description here

But, when I restart the computer I used to get the message "Repairing Automatic Recovery" which would then eventually go into Windows Recovery environment. I have since added bcdedit /set $variable recoveryenabled No, which makes it so it cannot possibly go into the recovery environment, but I get a different error now:

The application or operating system couldn't be loaded because a required file is missing or contains errors.

File: \EFI\Boot\bootx64.efi Error code: 0xc000007b

But, if I go into boot options and select this file manually, it boots into winpe just fine.

I'm not really sure what's going wrong, any help would be greatly appreciated.

How can I fix my code to allow me to successfully boot into Windows PE on my flash drive?

Clintclintock answered 31/5, 2018 at 17:22 Comment(11)
I disagree with the close vote because I'm asking specifically how to fix my code to work as expected. It's not a general computer problem, it's a specific problem with my powershell script.Clintclintock
0xc000007b is normally a .net framework error. What's your .net framework version ?Achievement
@FrédéricBonneau That error pops up on a bluescreen when the computer is restarted and attempts to boot into the flash drive. I don't know the .net framework version because it may be ran on hundreds of different models of computers that have different configurations.Clintclintock
I understand. check the .net framework version on the computer where you created the flash driveAchievement
@FrédéricBonneau But the flash drive itself works fine when I manually select the .efi file to boot into. The process for creating the flash drive is just dragging and dropping the files onto the flash drive, and it works out of the box. It's not an issue with the flash drive, that part works.Clintclintock
@GrumpyCrouton, see if this github.com/firstof9/upi/blob/… or this throws any light github.com/7heMC/SteadierState/blob/…Viridity
That first one requires Assessment and Deployment Kit which doesn't work for me because my purpose for wanting to boot to the flash drive is because these computers I'm running it on are manufacturer default, and must remain that way, plus it would be even less convenient to have to install this on every computer just to boot to the flash drive in 1 click instead of 3. and the 2nd one I don't really think is related at all, that's used when already booted into the flash drive it seems.Clintclintock
Is secureboot blocking it? Have you seen this question & solution.Annalist
@Annalist Possibly? I'm not sure, because I can boot into the flash drive fine if I manually select the EFI file in Change Boot Device during the startup of the computer. That's an interesting solutionClintclintock
Does your flash drive actually have an F: partition (Flash drives are often not actually partitioned therefore the partition identifier may not be the appropriate one)Cabral
@ADHDCat That is the letter that pops up inside windows explorer, that's all I know about thatClintclintock
P
-1

This problem can be depending from a different perspective of what is named as c: between the moment you run the powershell and the moment the system is going to boot.

Can you try this ?

Boot by using the USB drive open a console and type:

bcdedit / export C: \ SAVEDBCD

I expect that C: in this case should correspond to your pendrive, isn't it ?

Then reboot normally, execute your powershell script.

You should notice that the pendrive letter you get in $drive is not c:\ since when the system started the C:\ is already occupied from the hard disk primary windows partition.

Now compare the previously saved SAVEBCD file with the one present in c:\boot\bcd, you should make them equal in order to have the boot working , so likely you just need to start your code with:

$drive="c:"
Potamic answered 7/6, 2018 at 13:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.