Search code examples
batch-filebcdedit

batch file FOR loop weird output with "bcdedit"


I am trying to understand the FOR loop in batch files. This code:

FOR /F %%V IN ('bcdedit') DO @echo %%V
pause
exit

Gives this output:

C:\Users\me\Desktop>FOR /F %V IN ('bcdedit') DO @echo %V
The
Access

C:\Users\me\Desktop>pause
Press any key to continue . . .

bcdedit is a program to configure the boot manager. running bcdedit at the console gives:

Windows Boot Manager                                                            
--------------------                                                            
identifier              {bootmgr}                                               
device                  partition=\Device\HarddiskVolume1                       
description             Windows Boot Manager                                    
locale                  en-US                                                   
inherit                 {globalsettings}                                        
integrityservices       Enable                                                  
default                 {current}                                               
resumeobject            {5af9a946-5290-11e3-bd93-d2aed7e9b7a5}                  
displayorder            {current}                                               
toolsdisplayorder       {memdiag}                                               
timeout                 30                                                      

Windows Boot Loader                                                             
-------------------                                                             
identifier              {current}                                               
device                  partition=C:                                            
path                    \Windows\system32\winload.exe                           
description             Windows 8.1                                             
locale                  en-US                                                   
inherit                 {bootloadersettings}                                    
recoverysequence        {5af9a948-5290-11e3-bd93-d2aed7e9b7a5}                  
integrityservices       Enable                                                  
recoveryenabled         Yes                                                     
allowedinmemorysettings 0x15000075                                              
osdevice                partition=C:                                            
systemroot              \Windows                                                
resumeobject            {5af9a946-5290-11e3-bd93-d2aed7e9b7a5}                  
nx                      OptIn                                                   
bootmenupolicy          Standard                                                
useplatformclock        Yes

Where do the words "The" and "Access" come from?


Solution

  • You ran bcdedit without Admin privileges, which produces the following output:

    The boot configuration data store could not be opened.
    Access is denied.
    

    Your output comes from the first word on each line. Make sure you are running in an elevated command prompt.