如何从脚本本身中获取 windows .bat 脚本的名称?

Rya*_*ery 3 windows batch-file vbscript nant

我有一个 .bat 文件。我想以编程方式获取 .bat 文件的名称。我怎样才能做到这一点?

这是我的最终目标

"..\lib\nant\nant.exe" -buildfile:nant.build {{pass in name of this file here}}
pause
Run Code Online (Sandbox Code Playgroud)

Set*_*eth 10

for /?在命令行上试试。帮助显示了各种有用的文件名替换,例如:

%~I         - expands %I removing any surrounding quotes (")
%~fI        - expands %I to a fully qualified path name
%~dI        - expands %I to a drive letter only
%~pI        - expands %I to a path only
%~nI        - expands %I to a file name only
%~xI        - expands %I to a file extension only
Run Code Online (Sandbox Code Playgroud)

将 I 替换为 0 以获取批处理文件名,并将 I 替换为 1、2、3 等以获取参数名称。