文件文件夾映射junction和mklink,創建軟硬鏈接
一、mklink
Vista系統開始提供的,創建軟鏈接,硬鏈接的命令
語法:
Java代碼- D:\>mklink
- 創建符號鏈接。
- MKLINK [[/D] | [/H] | [/J]] Link Target
- /D 創建目錄符號鏈接。默認為文件
- 符號鏈接。
- /H 創建硬鏈接,而不是符號鏈接。
- /J 創建目錄聯接。
- Link 指定新的符號鏈接名稱。
- Target 指定新鏈接引用的路徑
- (相對或絕對)。
/d:建立目錄的符號鏈接 (symbolic link)
/j:建立目錄的軟鏈接(聯接)(junction)
/h:建立文件的硬鏈接 (hard link)
D:\>mklink /d "D:\imagesd" "D:\images" (可以指向遠程目錄)
mklink /d d:\develop \\138.20.1.141\e$\develop
D:\>mklink /h "D:\imagesh.rar" "D:\images.rar" (只能對文件操作,不能跨盤符)
D:\>mklink /j "D:\imagesj" "D:\images" (與junction.exe效果相同)
我一般使用/d
二、junction
junction.exe是一個命令行工具,
是微軟提供的創建文件或文件夾軟鏈接(聯接)(junction)的工具,
可實現文件或文件夾的映射
Junction v1.06 下載
https://technet.microsoft.com/en-us/sysinternals/bb896768
https://download.sysinternals.com/files/Junction.zip
語法:
Java代碼- D:\>D:\junction.exe
- Junction v1.06 - Windows junction creator and reparse point viewer
- Copyright (C) 2000-2010 Mark Russinovich
- Sysinternals - www.sysinternals.com
- The first usage is for displaying reparse point information, the
- second usage is for creating a junction point, and the last for
- deleting a junction point:
- usage: D:\junction.exe [-s] [-q] <file or directory>
- -q Don‘t print error messages (quiet)
- -s Recurse subdirectories
- usage: D:\junction.exe <junction directory> <junction target>
- example: junction d:\link c:\windows
- usage: D:\junction.exe -d <junction directory>
創建聯接
junction.exe -s 映射後地址 源地址
D:\junction.exe -s D:\imagesjuction D:\images
刪除聯接
junction.exe -d 映射後地址
D:\junction.exe -d D:\imagesjuction
junction.exe 與 mklink /j 效果相同
Notethat Windows does not support junctions to directories on remote shares.
文件文件夾映射junction和mklink,創建軟硬鏈接