mklinkmklink

建立目錄或檔案符號或硬式連結。Creates a directory or file symbolic or hard link.

語法Syntax

mklink [[/d] | [/h] | [/j]] <link> <target>

參數Parameters

參數Parameter 描述Description
/d/d 建立目錄符號連結。Creates a directory symbolic link. 根據預設,此命令會建立檔案符號連結。By default, this command creates a file symbolic link.
/h/h 建立硬式連結,而不是符號連結。Creates a hard link instead of a symbolic link.
/j/j 建立目錄連接點。Creates a Directory Junction.
<link> 指定要建立之符號連結的名稱。Specifies the name of the symbolic link being created.
<target> 指定新符號連結所參考 (相對或絕對) 路徑。Specifies the path (relative or absolute) that the new symbolic link refers to.
/?/? 在命令提示字元顯示說明。Displays help at the command prompt.

範例Examples

若要從根目錄建立名為 MyFolder 的符號連結,並將其從根目錄中移除,並將名為 Myfile.txt 的硬式連結,輸入到目錄中的範例檔案,請輸入:To create and remove a symbolic link named MyFolder from the root directory to the \Users\User1\Documents directory, and a hard link named Myfile.file to the example.file file located within the directory, type:

mklink /d \MyFolder \Users\User1\Documents
mklink /h \MyFile.file \User1\Documents\example.file
rd \MyFolder
del \MyFile.file

其他參考資料Additional References