|  | 
| 你需要理解的是call的作用和对变量的处理  一行命令里的变量在执行这行命令之前就已经被扩展了
 
 假设当前root为(cd)   不存在变量bootroot
 
 如果写成  find --set-root /bootmgr && set bootroot=%@root%
 
 执行时被扩展为  find --set-root /bootmgr && set bootroot=(cd)  执行结果为变量bootroot的值是(cd)
 
 如果写成  find --set-root /bootmgr && set bootroot=%@root^%
 
 执行时被扩展为  find --set-root /bootmgr && set bootroot=%@root%  执行结果为变量bootroot的值是%@root%这个字符串  没有被扩展
 
 如果写成  find --set-root /bootmgr && call set bootroot=%@root^%
 
 执行时被扩展为 find --set-root /bootmgr && call set bootroot=%@root%
 
 假设在(hd0,0)上找到了文件  那当前root为(cd)  执行find --set-root /bootmgr后当前root为(hd0,0)  执行call会进入新的环境  在新环境中先扩展call后面的set bootroot=%@root%命令为set bootroot=(hd0,0)  然后执行set bootroot=(hd0,0)  最终执行完毕后变量bootroot值为(hd0,0)
 
 假如所有设备上都找不到/bootmgr文件  执行find --set-root /bootmgr会失败  不再执行&&符号后面的call set bootroot=%@root%  最终执行完毕后还是不存在变量bootroot
 
 | 
 评分
查看全部评分
 |