文件文件夹映射junction和mklink,创建软硬链接
一、mklink
Vista系统开始提供的,创建软链接,硬链接的命令
语法:
- 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
语法:
- 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.