您在批处理文件脚本中称之为什么? %VARIABLE:~2%
所以,当我设置一个变量,然后从该变量中选择一个位置时,我试图弄清楚这是什么?
实施例
SET TEST=FOO BAR 123
SET VAR=%TEST:~4,3%
如果我回复%VAR%我知道它会返回" BAR",但我不知道这叫什么,我只需要通过更改值和检查我自己解决它返回了什么。
谢谢。
答案 0 :(得分:1)
Microsoft Windows [Version 10.0.10240] (c) 2015 Microsoft Corporation. All rights reserved. C:\Windows\system32>set /? Displays, sets, or removes cmd.exe environment variables. SET [variable=[string]] variable Specifies the environment-variable name. string Specifies a series of characters to assign to the variable. Type SET without parameters to display the current environment variables. If Command Extensions are enabled SET changes as follows: ... Environment variable substitution has been enhanced as follows: %PATH:str1=str2% would expand the PATH environment variable, substituting each occurrence of "str1" in the expanded result with "str2". "str2" can be the empty string to effectively delete all occurrences of "str1" from the expanded output. "str1" can begin with an asterisk, in which case it will match everything from the beginning of the expanded output to the first occurrence of the remaining portion of str1. May also specify substrings for an expansion. %PATH:~10,5% would expand the PATH environment variable, and then use only the 5 characters that begin at the 11th (offset 10) character of the expanded result. If the length is not specified, then it defaults to the remainder of the variable value. If either number (offset or length) is negative, then the number used is the length of the environment variable value added to the offset or length specified. %PATH:~-10% would extract the last 10 characters of the PATH variable. %PATH:~0,-2% would extract all but the last 2 characters of the PATH variable. ... C:\Windows\system32>