21
A
回答
23
echo %~f0
为我工作。
7
%CD%给出当前目录。
%〜DP0会给你的目录中的脚本是
IE:脚本在C:\文件夹中,我把它从C:\ otherfolder
%CD%= C:\ otherfolder
%〜DP0 = C:\文件夹
(我敢肯定,99%我已经得到了全面的正确的方式,但没有拿到窗口去检查ATM)。
编辑:从那里,使用你已经得到了一个,你应该能够得到批处理文件名
30
为了您的信息,
您将需要启用命令扩展,这不是赢得2000年之前就存在(我不知道NT4)
SEE内容:cmd.exe /?
/E:ON Enable command extensions (see below)
/E:OFF Disable command extensions (see below)
命令扩展在Windows上默认启用。
我建议阅读的另一个帮助是FOR命令。 它包含那些国旗的完整含义。
SEE:for /?
In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~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
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$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
The modifiers can be combined to get compound results:
%~dpI - expands %I to a drive letter and path only
%~nxI - expands %I to a file name and extension only
%~fsI - expands %I to a full path name with short names only
%~dp$PATH:I - searches the directories listed in the PATH
environment variable for %I and expands to the
drive letter and path of the first one found.
%~ftzaI - expands %I to a DIR like output line
In the above examples %I and PATH can be replaced by other valid
values. The %~ syntax is terminated by a valid FOR variable name.
Picking upper case variable names like %I makes it more readable and
avoids confusion with the modifiers, which are not case sensitive.
+0
只是用0代替我 – waza123 2016-05-17 18:19:13
1
“%〜F0”
“%〜dpnx0”
上述要么给人的完全合格的路径。将其用双引号括起来以防路径中包含空格。
0
调用脚本: “FIRST.BAT”:
call second.bat %0 parameter-a parameter-b
调用的脚本: “SECOND.BAT”:
echo The name of this called script should be "SECOND", proof: %~n0
echo The 1st parameter passed should be "FIRST", proof: %1 shift
echo The name of the calling script should be "FIRST", proof: %~n0
echo The 1st parameter should be "parameter-a", proof: %1
相关问题
- 1. 在批处理文件中运行几个批处理文件
- 2. 运行批处理文件
- 3. 运行批处理文件
- 4. 运行批处理文件
- 5. 运行批处理文件
- 6. DOS批处理文件查找丢失的顺序文件名
- 7. Windows批处理文件在文件名中查找字符串
- 8. 从另一个批处理文件运行批处理文件
- 9. 从C批处理文件运行批处理文件#
- 10. 批处理文件以查找文件名
- 11. 批处理文件运行PowerShell的
- 12. 运行批处理文件的返回
- 13. 无法运行的批处理文件
- 14. phpdoc在批处理文件中运行
- 15. 在python中运行批处理文件
- 16. 在后台运行批处理文件
- 17. 在PowerShell中运行批处理文件
- 18. 在vb.net中运行批处理文件?
- 19. 在Mac上运行批处理文件
- 20. 在VC++中运行批处理文件
- 21. 在Win7中运行批处理文件
- 22. 在批处理文件中查找基于时间的文件
- 23. 批处理命令查找并运行文件
- 24. 在批处理文件中运行批处理脚本
- 25. 在另一个批处理文件中运行批处理文件
- 26. 批处理文件在Windows中运行其他批处理文件
- 27. 在访问文件夹时运行的批处理文件
- 28. 在文本文件上查找字符串 - 批处理文件
- 29. 在unicode中命名的文件上运行批处理
- 30. 获取正在运行的批处理文件
我不太明白你的要求。 %0是您键入的启动脚本的内容。脚本是否启动了另一个?它与另一个链接?请提供更多信息。 – jim 2008-12-05 11:13:57
如果您只是使用%0,您将无法获得完全限定的路径名称。为了引用其他应用程序中的批处理文件%0是不够的。 – Martin 2008-12-08 10:25:42