windows 8 - How do I create a junction on Win8?

26
2013-08
  • Chloe

    I tried the following:

    C:\Users\Chloe\Documents>dir /a "My Music"
     Volume in drive C is OS
     Volume Serial Number is 808A-8F0B
    
     Directory of C:\Users\Chloe\Documents\My Music
    
    File Not Found
    
    C:\Users\Chloe\Documents>mklink /j "My Music" "c:\Users\Chloe\Music"
    Cannot create a file when that file already exists.
    

    WTF?

    C:\Users\Chloe\Documents>mklink
    Creates a symbolic link.
    
    MKLINK [[/D] | [/H] | [/J]] Link Target
    
            /D      Creates a directory symbolic link.  Default is a file
                    symbolic link.
            /H      Creates a hard link instead of a symbolic link.
            /J      Creates a Directory Junction.
            Link    specifies the new symbolic link name.
            Target  specifies the path (relative or absolute) that the new link
                    refers to.
    
  • Answers
  • Alex P.

    The junction is already there... you just did not check for it properly. Try:

    cd C:\Users\Chloe\Documents
    dir /ah "My Music*"
    
  • Chloe

    I had to delete those directories in Explorer. Despite using fsutil reparsepoint delete "My Music". They would not show up with dir /a after I 'deleted' them, but they did show up with dir /a before I 'deleted' them. They still showed up in Explorer after the command line 'delete'. I even rebooted and they were there. I deleted in Explorer, and re-created the junctions/links. Must be a bug in Windows.


  • Related Question

    windows 7 - How can I create a right click menu item to manipulate a junction point?
  • Tom Wijsman

    As I am using a SSD but it is limited in size I want to be able to use junction points to remap files and directories to my HDD, this would work ideal if I could create a shell extension for it that does this.

    The ideal behavior would be to right click a directory or junction point and have an option
    "Manipulate junction point" in which I can perform the following actions:

    • Create: For a directory, move the directory to a location I specify and replace it by a junction point.
      (Dir) C:\Example turns into (JP) C:\Example --> D:\Example

    • Swap: For a junction point, I want to swap the junction point with its location.
      (JP) C:\Example --> (Dir) D:\Example turns into (Dir) C:\Example <-- (JP) D:\Example

      This means it would remove the junction point, move the data and place a reverse junction point.

    • Remove: For a junction point, I want to remove it and move the directory back.
      (JP) C:\Example --> (Dir) D:\Example turns into (Dir) C:\Example

    My most important questions:

    • What approach should I take to do this? Script? Bash? Executable?
    • How do I create the menu entry?

    Less important questions:

    • Does there exist such a solution already?
    • Are there better commands or API calls for checking and manipulating junction points?

    I already know of Microsoft's mklink and Sysinternals junction.


  • Related Answers
  • Isxek

    Since you asked if such solutions exist already, have you taken a look at Junction Link Magic or Link Shell Extension?

    Junction Link Magic allows creation, modification, and removal of junction points. It is freeware, and does support Windows 7.

    Link Shell Extension also provides the same functionality, and is also freeware. It also supports Windows 7.

  • Randolph West

    I just use MKLINK which is built into Windows 7. You'll end up writing batch files I guess, but it's not hard to use.