博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
在Windows Vista中使用符号链接
阅读量:2514 次
发布时间:2019-05-11

本文共 4368 字,大约阅读时间需要 14 分钟。

One of the long-awaited features in Windows Vista was the ability to use symbolic links, the way you can in linux. Sadly, they don’t work quite as well as they could, but it’s a big upgrade from prior versions, and has solved a number of problems for me already.

Windows Vista中人们期待已久的功能之一就是能够使用符号链接,这是在Linux中的一种方式。 令人遗憾的是,它们的运行状况不尽如人意,但这是对先前版本的重大升级,并且已经为我解决了许多问题。

使用mklink命令 (Using the mklink Command)

The command that you need to use is mklink, which you’ll use from the command line. Just type it on the command line to see the options:

您需要使用的命令是mklink ,您将在命令行中使用它。 只需在命令行上输入即可查看选项:

C:\Users\geek>mklinkCreates a symbolic link.MKLINK [[/D] | [/H] | [/J]] Link Target        /D      Creates a directory symbolic link.  Default is a file                symbolic link.        /H      Creates a hard link instead of a symbolic link.        /J      Creates a Directory Junction.        Link    specifies the new symbolic link name.        Target  specifies the path (relative or absolute) that the new link                refers to.
C:\Users\geek>mklinkCreates a symbolic link.MKLINK [[/D] | [/H] | [/J]] Link Target        /D      Creates a directory symbolic link.  Default is a file                symbolic link.        /H      Creates a hard link instead of a symbolic link.        /J      Creates a Directory Junction.        Link    specifies the new symbolic link name.        Target  specifies the path (relative or absolute) that the new link                refers to.

For instance, if you wanted to make the folder C:\Users\Geek\TestFolder available from C:\TestFolder as well, you could use the following command.

例如,如果您还想使文件夹C:\ Users \ Geek \ TestFolder也可以从C:\ TestFolder使用,则可以使用以下命令。

C:\mklink /D C:\TestFolder C:\Users\Geek\TestFoldersymbolic link created for C:\TestFolder <<===>> C:\Users\Geek\TestFolder

C:\ mklink / DC:\ TestFolder C:\ Users \ Geek \ TestFolders为C:\ TestFolder创建的符号链接<< === >> C:\ Users \ Geek \ TestFolder

Now if you look in C:\TestFolder directory, you’ll see whatever files were in the other directory.

现在,如果您查看C:\ TestFolder目录,您将看到另一个目录中的所有文件。

了解选项。 (Understanding the Options.)

MKLINK link target

MKLINK链接目标

Using the command without any extra options creates a soft link to a file.

使用不带任何其他选项的命令会创建到文件的软链接。

/D creates a symbolic link, or a soft link.

/ D创建符号链接或软链接。

This essentially acts like a shortcut to a folder in prior versions of Windows, except you don’t have to use an actual shortcut.

在本质上,这与Windows早期版本中的文件夹快捷方式一样,除非您不必使用实际的快捷方式。

/H creates a hard link, which points directly to the file.

/ H创建一个硬链接,该链接直接指向该文件。

This option can’t be used for folders directly for some reason, you’ll have to use the next option.

由于某些原因,该选项不能直接用于文件夹,您必须使用下一个选项。

/J creates a “Directory Junction”

/ J创建一个“目录连接”

A Directory Junction is actually just a hard link to a directory. This is a feature that existed prior to Vista as well. If you are trying to symlink to a directory using a hard link, then you should use this option.

目录连接实际上只是到目录的硬链接。 这是Vista之前也存在的功能。 如果尝试使用硬链接符号链接到目录,则应使用此选项。

了解硬链接与软链接 (Understanding Hard vs Soft Links)

Hard Link

硬链接

A hard link directly points to the file, and acts to the operating system as if it is the file itself. You’ll want to use this option the majority of the time if you are trying to fake an application’s directory.

硬链接直接指向文件,并像文件本身一样作用于操作系统。 如果要伪造应用程序的目录,则通常需要使用此选项。

Soft Link

软链接

A soft link is essentially a shortcut to a file or folder – if you are using Windows explorer, you’ll be redirected to the directory if you double-click on a shortcut, it won’t pretend its part of the filesystem. You can still directly reference or open a file with the symlinked path, and it mostly works.

软链接本质上是指向文件或文件夹的快捷方式-如果您使用的是Windows资源管理器,则双击快捷方式将重定向到该目录,它不会伪装成文件系统的一部分。 您仍然可以直接使用符号链接的路径引用或打开文件,并且该文件大多数都可以使用。

使用网络共享中的符号链接 (Using Symlinks from a Network Share)

One of the things that’s been extensively discussed is that you cannot use the Vista symlinks from another operating system (not surprising), but you cannot use them from a network share either. This is troublesome if you expect to use this feature on a web server or a file server.

被广泛讨论的一件事是,您不能使用来自另一个操作系统的Vista符号链接(不足为奇),但是您也不能从网络共享中使用它们。 如果您希望在Web服务器或文件服务器上使用此功能,则很麻烦。

删除符号链接 (Deleting Symlinks)

To delete a symlink, you can just delete the link. Just make sure you don’t delete the original file.

要删除符号链接,您只需删除链接。 只要确保您不删除原始文件即可。

翻译自:

转载地址:http://dovwd.baihongyu.com/

你可能感兴趣的文章
采访吴岳师兄有感 by 王宇飞
查看>>
LVS简略介绍
查看>>
hdu 1021 Fibonacci Again
查看>>
JVM架构_XmnXmsXmxXss有什么区别:转
查看>>
PHPExcel 使用心得
查看>>
洛谷 P3374 【模板】树状数组 1(单点加,区间和)
查看>>
verilog 代码编写小记
查看>>
PyQT的安装和配置
查看>>
从 docker 到 runC
查看>>
守护进程
查看>>
第十二周作业
查看>>
php数组
查看>>
Linux 防火墙
查看>>
互联网金融P2P主业务场景自动化测试
查看>>
array_filter函数的应用
查看>>
html,body
查看>>
一个Brushes笔画应用ios源码完整版
查看>>
IOS 网络浅析-(七 JSON解析之三方JSONKit)
查看>>
image的srcset属性
查看>>
vs + Qt 环境下配置QCustomPlot编译不通过
查看>>