我的批处理文件中有这一行@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
和%~3
是ARGV
论点。当我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%
并将其值分配给%~1
(myvar
)。
显示结果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] 删除。
我来说两句