Problems Adding Boot Option to Windows 10


Joined
Jan 23, 2017
Messages
5
Reaction score
0
Hi, Hoping someone can help.

I am trying to create a command line program that adds a WinPE boot option when the user runs a program called "Recovery", the object being that the user can use a bespoke image to recover the system .. but it is only available by running this program.

I have my hard drive set up with a 300MB system partition, a 16MB Microsoft reserved partition, a Recovery Partition (called SMARTBOX that has WinPE on it ) and an Micro SD drive that contains the bespoke image.

My Recovery program (in part) is as follows;

Code:
REM ** FIND IS SD CARD IS INSERTED

WMIC DISKDRIVE GET CAPTION,NAME > %DES%\DD.TXT
FOR /F "TOKENS=1 DELIMS=" %%i IN ('FIND /I "CARD" "%DES%\DD.TXT"') DO SET SD=%%i
DEL %DES%\DD.TXT /Q
IF DEFINED SD (ECHO.) ELSE (GOTO ER1)

REM ** FIND 'SMARTBOX' PARTITION

ECHO SEL DISK 0 > %DES%\DP1.TXT
ECHO LIST VOL >> %DES%\DP1.TXT
DISKPART /S %DES%\DP1.TXT > %DES%\RECOVERY.TXT
DEL %DES%\DP1.TXT
FOR /F "TOKENS=1 DELIMS=" %%j IN ('FIND /I "SMARTBOX" "%DES%\RECOVERY.TXT"') DO SET RECOVER=%%j
IF DEFINED RECOVER (ECHO.) ELSE (GOTO ADDRECOVER)
FOR /F "TOKENS=1,2 DELIMS= " %%a IN ("%RECOVER%") DO SET /A WINPE=%%b

FIND ** FIND SYSTEM PARTITION

FOR /F "TOKENS=1 DELIMS=" %%k IN ('FIND /I "SYSTEM" "%DES%\RECOVERY.TXT"') DO SET SYS=%%k
FOR /F "TOKENS=1,2 DELIMS= " %%a IN ("%SYS%") DO SET /A SYSTEM=%%b
DEL %DES%\RECOVERY.TXT

REM ** ASSIGN DRIVE LETTERS TO SMARTBOX AND SYSTEM PARTITIONS

ECHO SEL DISK 0 > %DES%\DP1.TXT
ECHO SEL VOL %WINPE% >> %DES%\DP1.TXT
ECHO ASSIGN LETTER=Y: >> %DES%\DP1.TXT
ECHO SEL VOL %SYSTEM% >> %DES%\DP1.TXT
ECHO ASSIGN LETTER=S: >> %DES%\DP1.TXT

DISKPART /S %DES%\DP1.TXT
DEL %DES%\DP1.TXT

REM ** ADD WINPE BOOT TO BOOT MENU

set BCDEDIT=%SYSTEMROOT%\system32\bcdedit.exe
set BCDSTORE=S:\Boot\BCD
for /f "tokens=3" %%A in ('%BCDEDIT% /store %BCDSTORE% /create /application osloader') do set guid=%%A
%BCDEDIT% /store %BCDSTORE% /set %guid% systemroot \Windows
%BCDEDIT% /store %BCDSTORE% /set %guid% detecthal Yes
%BCDEDIT% /store %BCDSTORE% /set %guid% winpe Yes
%BCDEDIT% /store %BCDSTORE% /set %guid% osdevice ramdisk=[boot]\sources\boot.wim,{ramdiskoptions}
%BCDEDIT% /store %BCDSTORE% /set %guid% device ramdisk=[boot]\sources\boot.wim,{ramdiskoptions}
%BCDEDIT% /store %BCDSTORE% /set %guid% description "Smartbox Recovery"
%BCDEDIT% /store %BCDSTORE% /displayorder %guid% /addfirst
c:\windows\system32\shutdown.exe /r /t 0
Everything completes ok with no errors, however on re-boot I have no boot options menu, it just boots directly into windows 10 as if no new boot option had been added.

Any help appreciated.
 
Ad

Advertisements

Joined
Jun 6, 2016
Messages
73
Reaction score
21
Hi Fugazi,

My boot menu always shows. I was trying to find your answer for you. As far as I got was reading some BCDedit stuff on this Winearo site. http://winaero.com/blog/how-to-disable-windows-8-boot-logo-spining-icon-and-some-other-hidden-settings/

I finally downloaded the winearo Tweaker and on my system, when I brought up the boot options screen the option for "Always show Boot Menu" was already checked. Although this utility obviously issues the current BCDedit set command to toggle that setting on/off, its not clear on the web site how its done.

Here is a screenshot to explain: I found that option already checked.

upload_2017-1-23_22-54-0.png


BTW, clicking on the blue link in the app takes you to the website I started at before I downloaded the app.

I know you would rather I just had the BCDedit set command for you, but hopefully this may point you in the right direction. And you did say "Any Help appreciated" big grin.

cheers,
 
Joined
Feb 22, 2014
Messages
1,379
Reaction score
268
There is also EasyBCD. - http://neosmart.net/EasyBCD/

EasyBCD is a powerful bootloader-modification tool that has a wide-range of applications and usages. It can perform a variety of tasks ranging in complexity and application from the most basic to advanced and highly-customizable features.

Please use EasyBCD with care, it’s a powerful tool that you can either make your life a lot easier or make it rather miserable by letting you shoot yourself in the foot.

EasyBCD is free for personal use at home, otherwise a commercial license is available with instant download from our online store.
 
Joined
Jun 6, 2016
Messages
73
Reaction score
21
Hi Clifford,

If you read Fugazi's post a second time, you will see that he doesn't need EasyBCD, or Winero for that matter. He is looking for the BCDEdit set command line parameter to show the boot menu from within his script. He is working on an automation task.

I just used the Winero screen shot to explain to Fugazi my machine has something already set to display the boot menu: as graphically shown by the screenshot.

cheers
 
Joined
Feb 22, 2014
Messages
1,379
Reaction score
268
If you read Fugazi's post a second time, you will see that he doesn't need EasyBCD
Actually no I can't. I have no idea what they are trying to do with that code. I assumed they could use any boot menu. But if that is not the case then ignore what I suggested.
 
Joined
Jan 23, 2017
Messages
5
Reaction score
0
Firstly thank you both for responding, secondly what I am tying to do has to be done using command line coding due to certain limitations.
 
Ad

Advertisements

Joined
Feb 22, 2014
Messages
1,379
Reaction score
268
If you can boot to the partition with Command-line code, the Boot menu can turn control over to command line when Recovery is selected. There is no need in having the menu in Command-line code. What you are likely needing is a Boot Manager that resides in the MBR. Which would then remove any restriction Windows boot files may have on the recovery process.

I may not know how to add a menu to the Commandline script, but I do understand about limitations. That is if I knew what those limitations being faced are.
 
Joined
Jun 6, 2016
Messages
73
Reaction score
21
Hi Clifford,

It was not my intent to anger you. Actually I have EASY BCD 2.3. I used it to assist me in getting my boot menu sorted the way I wanted. And for what it's worth, I was also about to recommend it. But then I went back to have another look and realized he was looking for a BCDEdit command line to add to his script. My intent was to pass that on to you in hope you could shake your large bag of solutions and maybe find what I couldn't .

I just hope between the 2 of us, we can help him.

Hi Fugazi, Perhaps this is what you are looking for:

bcdedit /set {bootmgr} displaybootmenu yes

To toggle it back off

bcdedit /set {bootmgr} displaybootmenu no
 
Joined
Feb 22, 2014
Messages
1,379
Reaction score
268
Still yet I'm not so sure BCDedit is a solution either, as it edits the same menu as EasyBCD and Winaero Tweaker. I have a feeling the use of that menu is the cause of the limitation. I could be wrong but unfortunately I don't know which limitation they are facing.
 
Joined
Jun 6, 2016
Messages
73
Reaction score
21
Sometimes I wonder if I'm sure of anything these days. lol

BCDEdit is part of windows distribution and he is already using it in his script. I also wonder about his "limitations" too, Typically, the purpose of a script type program is to run a bunch of commands multiple times without human intervention. I believe that's why he can't use the GUI tools, as they all require human intervention.

For example, maybe he has to deploy this on hundreds of current/future windows workstations overnight. In that situation,limitations might be manpower, no over time, and no work day interruption for the current workstations. And then the script becomes part of their process that configures brand new workstations automatically.

And if I am all wrong with that, I'm going to say it's cost! and stick to that! lol funny how limitations and cost can sometimes be interchangeable terms..
 
Ad

Advertisements

Joined
Jan 23, 2017
Messages
5
Reaction score
0
Hi all, sorry for the delayed response .. I had to put this on hold for a while as something more important came up.

I managed to achieve what I wanted by adding the following to the script

Code:
%BCDEDIT% /store %BCDSTOR% /DEFAULT %guid%
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top