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>mklink Creates 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>mklink Creates 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.
要刪除符號鏈接,您只需刪除鏈接。 只要確保您不刪除原始文件即可。
翻譯自: https://www.howtogeek.com/howto/windows-vista/using-symlinks-in-windows-vista/