gpt4 book ai didi

windows - 找出正在运行的批处理文件的文件名

转载 作者:可可西里 更新时间:2023-11-01 12:11:27 25 4
gpt4 key购买 nike

在 Windows 批处理文件中,我想弄清楚这个批处理文件的完全限定路径名是什么。

我试过 %0 但这只给了我键入的命令(例如,只有没有路径或扩展名的文件名)。

最佳答案

供您引用,

你需要启用command extends,Win 2000之前是不存在的(我不知道NT4)

查看:cmd.exe/?

/E:ON   Enable command extensions (see below)
/E:OFF Disable command extensions (see below)

Windows 默认启用命令扩展。

我建议阅读的另一个帮助是 FOR 命令。它包含这些标志的完整含义。

查看:for/? 来自 cmd

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.

关于windows - 找出正在运行的批处理文件的文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/343518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com