Creating a Windows XP Junction
I need to create a Junction point (directory symbolic link) from C:\x to C:\xxx\yyy\zzz\aaa\bbb since I am running up against the Windows XP maximum file path length when adding files to this directory and I have no control over the directory 开发者_Python百科structure.
I was reading that creating Junction points is not built-in to Windows so I will need a tool or software library to do it. How can I create a Junction point in code? I was looking at using Junction, but legal is telling me that I cannot distribute it.
My codebase is primarily in Java. I would prefer to not introduce C/C++ to do this.
There is an open source (MIT license) tool named "ln-win" that should fit your requirements:
http://neosmart.net/blog/2011/open-source-100-compatible-ln-for-windows-and-junction-point-library/
https://github.com/NeoSmart/ln-win
Update: Unfortunately this tool does not work on Windows XP, it requires Windows Vista, Windows 7, Windows 2008 or higher.
Marc B had the right idea but did not post an answer so I will post this one.
This Windows article details the linkd
utility: http://support.microsoft.com/kb/205524/en-us
Linkd.exe
- Grafts any target folder onto a Windows 2000 version of NTFS folder
This EXE can be download via Windows Server 2003 Resource Kit Tools: http://www.microsoft.com/downloads/en/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd
Although it is for Windows 2003, it will install with no problems on Windows XP. Note that this kit is not compatible with Vista and Vista already has a built-in utility (mklink
) for creating Junction points.
One installed, a Junction can can be created:
linkd C:\x C:\xxx\yyy\zzz\aaa\bbb
The problem with mklink is, that there is no mklink.exe. (Meaning: You won't find it in your path, because it is built into cmd.exe.) Otoh, something like
cmd.exe /c mklink /j <junction_to_create> <actual_dir>
might work.
精彩评论