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?

Community
  • 1
  • 1
GrumpyCrouton
  • 8,486
  • 7
  • 32
  • 71
  • 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. – GrumpyCrouton May 31 '18 at 19:20
  • 0xc000007b is normally a .net framework error. What's your .net framework version ? – Bonneau21 Jun 04 '18 at 15:38
  • @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. – GrumpyCrouton Jun 04 '18 at 15:39
  • I understand. check the .net framework version on the computer where you created the flash drive – Bonneau21 Jun 04 '18 at 15:52
  • @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. – GrumpyCrouton Jun 04 '18 at 16:00
  • @GrumpyCrouton, see if this https://github.com/firstof9/upi/blob/e7bc5d8589b901a09d97af06203778d4b2d40143/windows%20scripts/win8pe.bat or this throws any light https://github.com/7heMC/SteadierState/blob/1602bd40d77c97fbe0ba979a8f843e70ec7c150e/prepnewpc.cmd – Tarun Lalwani Jun 04 '18 at 16:08
  • 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. – GrumpyCrouton Jun 04 '18 at 16:15
  • Is secureboot blocking it? Have you seen [this question & solution](https://superuser.com/questions/691656/windows-8-1-uefi-x64-is-not-able-to-boot-up-uefi-images). – pbhj Jun 05 '18 at 22:03
  • @pbhj 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 solution – GrumpyCrouton Jun 05 '18 at 22:20
  • 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) – FML Cat Jun 21 '18 at 03:22
  • @ADHDCat That is the letter that pops up inside windows explorer, that's all I know about that – GrumpyCrouton Jun 21 '18 at 04:02

1 Answers1

-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:"
A. Lion
  • 673
  • 5
  • 12