【问题标题】:batch file FOR loop weird output with "bcdedit"带有“bcdedit”的批处理文件FOR循环奇怪的输出
【发布时间】:2015-05-28 15:29:55
【问题描述】:

我正在尝试了解批处理文件中的 FOR 循环。这段代码:

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

给出这个输出:

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 是一个配置引导管理器的程序。 在控制台运行 bcdedit 给出:

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

“The”和“Access”这两个词从何而来?

【问题讨论】:

    标签: batch-file bcdedit


    【解决方案1】:

    您在没有管理员权限的情况下运行 bcdedit,会产生以下输出:

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

    您的输出来自每行的第一个单词。确保您在提升的命令提示符下运行。

    【讨论】:

      【解决方案2】:

      我会试试的

      FOR /F "delims=" %V IN ('bcdedit') DO @echo %V
      

      查看整行。

      我建议Access 可能是响应Access Denied 中的第一个标记

      【讨论】:

      • 谢谢。但是我尝试了您的代码,即使我在 bat 脚本的第二行有暂停,控制台窗口也如此快速地闪烁。我不得不使用 %%V。为什么?另一个问题......
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-07
      • 2023-04-08
      • 2021-07-26
      • 1970-01-01
      相关资源
      最近更新 更多