I can't create a junction from one sub-folder to another sub-folder without an error that the system cannot find the path specified ?

For example;
Source Path:
"C:\Users\<username>\Appdata\Roaming\<folderA>\<folderB>"

Target Path:
"C:\Custom Program Settings\<folderA>\"

In other words, I want the Source path specifically the sub-folder to belive that the Target path, subfolder; exists within the Source Path Subfolder ?

Recommended Answers

All 13 Replies

mklink /J

Entering that command won't do anything because you haven't specified the link name or the target name. The actual format is

mklink /j link target

Make sure that you use double quotes around link and target ig either or both contain spaces. I just created a junction and the command worked properly. I typed

D:\temp>mklink /j d:\temp\splunge d:\shared

And the result was (not a complete listing)

D:\temp>dir /p
Volume in drive D is Data
Volume Serial Number is E831-ED3D

Directory of D:\temp

2015-12-10  01:04    <DIR>          .
2015-12-10  01:04    <DIR>          ..
2015-10-02  21:18    <DIR>          bob
2015-10-01  12:13    <DIR>          BtSync
2015-09-30  20:44    <DIR>          Source
2015-12-10  01:04    <JUNCTION>     splunge [d:\shared]
2014-06-12  16:44               615 .comments.txt

I typed it out correctly :-(
I now get an error that the file already exists; what exactly, or strictly does this mean ?

If the name you are using for the new link is already in use as a file name then mklink cannot create the junction. For example, in D:\temp I have a file named test.avi. This is what happens when I run mklink:

D:\temp>mklink /j test.avi d:\shared
Cannot create a file when that file already exists.

In typical Micosoft fashion, the error message is misleading. It should say

Cannot create link because a file with that name already exists.

What if they are two different paths; shouldn't it work ?

I'm trying to create symbolic a link for Sublime-text;

I want the following path, to be tricked as though the files which exists in this path
C:\Custom Program Settings\Sublime-Packages

are really in this path;
C:\Users\<name>\AppData\Roaming\Sublime Text 2\Packages

mklink /j "C:\Custom Program Settings\Sublime-Packages" "C:\Users\<name>\AppData\Roaming\Sublime Text 2\Packages"
Cannot create a file when that file already exists ?

To achieve what you are wanting to do, you need to move all the files from C:\Custom Program Settings\Sublime-Packages to C:\Users\<name>\AppData\Roaming\Sublime Text 2\Packages and then Delete C:\Custom Program Settings\Sublime-Packages.

Once you've done that the mklink command will work.
i.e. All files destined for C:\Custom Program Settings\Sublime-Packages will be directed to C:\Users\<name>\AppData\Roaming\Sublime Text 2\Packages

Or is it the other way around?

mklink /j <link path> <Target>
(<link path> must not already exist)

mklink /j "C:\Users\<name>\AppData\Roaming\Sublime Text 2\Packages" "C:\Custom Program Settings\Sublime-Packages"
Where "C:\Users\<name>\AppData\Roaming\Sublime Text 2\Packages" must not already exist.

I see, both directories can't exist, or files.

The target directory with files can exist, but the link directory must not initially exist as an on disk directory.

Yes, why one directory / file must be deleted.

Yes, why one directory / file must be deleted.

If you mean the link source, it would be so that an empty directory or file can be created with the correct reparse attributes.

Yes, that is what I mean't ;-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.