本文介绍了启用和禁用延迟扩展,它有什么作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过 SETLOCAL ENABLEDELAYEDEXPANSION &SETLOCAL DISABLEDELAYEDEXPANSION 在许多批处理文件中,但这些命令实际上是做什么的?

I've seen SETLOCAL ENABLEDELAYEDEXPANSION & SETLOCAL DISABLEDELAYEDEXPANSION in many batch files but what do the commands actually do?

推荐答案

enabledelayeexpansion 指示 cmd 识别访问的语法 !var!varcurrent 值.disabledelayedexpansion 关闭了这个功能,所以 !var! 就变成了一个简单的字符串.

enabledelayeexpansion instructs cmd to recognise the syntax !var! which accesses the current value of var. disabledelayedexpansion turns this facility off, so !var! becomes simply that as a literal string.

在块语句(带括号的一系列语句)中,整个块被解析并然后执行.块中的任何 %var% 将被替换为该变量的值在块被解析时 - 在块被执行之前 - 同样的事情适用于 为...做(块).

Within a block statement (a parenthesised series of statements), the entire block is parsed and then executed. Any %var% within the block will be replaced by that variable's value at the time the block is parsed - before the block is executed - the same thing applies to a FOR ... DO (block).

使用 !var! 代替 %var% 访问 var 的更改值.

Using !var! in place of %var% accesses the changed value of var.

这篇关于启用和禁用延迟扩展,它有什么作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 14:06