“:2”在批处理文件的设置变量中是什么意思

亚瑟

我的批处理文件中有这一行@SET %~1=%~$PATH_VARNAME:2我看不到“:2”代表什么

更多细节:

@SET PATH_VARNAME=!%~3! 
@IF NOT DEFINED PATH_VARNAME SET PATH_VARNAME=%PATH%

@SET %~1=%~$PATH_VARNAME:2

%~1%~3ARGV论点。当我ECHO %~1在最后一组之后显示给我C:\Mycomuter\currentdir\example\interface\SET_LIB_PERL_GENE_CSV.bat

C:\Mycomuter\currentdir\example\interface\%PATH%环境变量中的第一个路径SET_LIB_PERL_GENE_CSV.bat是第二个ARGV参数

这行%~$PATH_VARNAME:2什么意思,是否采用PATH_VARNAME的第一个路径并将其与.bat文件(SET_LIB_PERL_GENE_CSV.bat的第二个参数连接起来

最好的祝福

迈克尔·希思
set "path_varname=%~dp0"
call :test myvar "%~nx0"
echo(%myvar%
exit /b

:test
set "%~1=%~$PATH_VARNAME:2"

在中搜索%~2%PATH_VARNAME%并将值设置为%~1

该示例将(脚本目录)中搜索%~2传递的%~nx0(脚本名称)%path_name%并将其值分配给%~1myvar)。

显示结果echo(%myvar%,它将是脚本的完整路径。

请参阅for /?底部提到的内容:

%~$PATH:I   - searches the directories listed in the PATH
               environment variable and expands %I to the
               fully qualified name of the first one found.
               If the environment variable name is not
               defined or the file is not found by the
               search, then this modifier expands to the
               empty string

PATH 可以是具有路径的任何有效变量。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章