如何在 Windows 上访问 $PWD 变量?

Jag*_*gte 4 windows command-line batch-file

linux下访问当前目录的变量是$PWD。在windows中如何访问$PWD对应的变量?

这是针对具有 unix 背景的用户。因此,查看有关 Windows 链接实用程序 mklink 的信息,我发现 mklink 的语法是

mklink "c:\where\link\is\to\be\created\file.txt"  "c:\where\file\actually\exists\file.txt"
Run Code Online (Sandbox Code Playgroud)

但我想用它代替

mklink $PWD "c:\where\file\actually\exists\file.txt"
Run Code Online (Sandbox Code Playgroud)

但使用 $PWD 会引发错误。我来自 Linux 世界,其中$PWD提到了当前工作目录。

$PWD正确的语法是什么,以便在执行脚本时创建链接?

Jag*_*gte 6

好的,我自己找到了答案,它似乎有效: mklink "%cd%\file.txt" "c:\where\file\actually\exists\file.txt"