Windows 7 上没有安装 mklink?

Windows 7 上没有安装 mklink?

我刚刚安装了 Windows 7 Pro,并根据自己的喜好对其进行配置。我要设置一个符号链接(因为它支持符号链接)。

但我好像没有这个mklink程序C:\Windows\system32

在 Powershell 的管理员模式下:

PS C:\> mklink
The term 'mklink' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spel
ling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:7
+ mklink <<<<
    + CategoryInfo          : ObjectNotFound: (mklink:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

答案1

mklink不是一个独立工具——它是 Cmd.exe 解释器中的内置命令。在外部运行它的唯一方法是通过cmd /c(类似于sh -c在 Linux 上):

cmd /c mklink参数

但是,PowerShell 本身支持创建各种链接类型使用New-Itemcmdlet,尽管它不是一个完整的替代品(因为它不支持创建相对的符号链接)。

新项目-ItemType符号链接|连接|硬链接-姓名-目标酒吧

答案2

解决方案是 mklink 是 cmd.exe 的内置函数。因此 Powershell 无法直接访问它。

无论是谁想到这个,都应受到负面赞扬。

答案3

PowerShell 不能完全替代 CMD。许多 CMD 功能在 PS 中不起作用。切换到 CMD 运行 mklink

相关内容