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

标签 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"

但是我想把它换成

mklink $PWD "c:\where\file\actually\exists\file.txt"

但是使用 $PWD 会抛出错误。我来自 linux 世界,其中 $PWD 指的是当前工作目录。

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

最佳答案

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

关于windows - 如何在 Windows 上访问 $PWD 变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17239185/

相关文章:

c++ - 限制程序对 unc 服务器的访问

windows - bat文件不会暂停执行

windows - 对 `SDL_main' 的 undefined reference

linux - 如何比较两个目录的大小?

batch-file - 尽管拥有完全控制权,Robocopy 访问仍被拒绝?

windows - 检测当前 Windows 版本是 32 位还是 64 位

windows - 使用 Terraform、Chef 或 Powershell 以编程方式设置 EBS 卷 Windows 驱动器盘符

command-line - azure devops 本地代理管道权限被拒绝

batch-file - 如何使 bat 文件在 x 秒内未完成时自行中止

unix 命令行 ...如何grep 并仅显示包含字符串的文件名?