152

I was reading http://web.archive.org/web/20160820000804/https://www.dropboxwiki.com/tips-and-tricks/sync-game-saves-across-multiple-computers, and I know junction/mklink worked in Windows 7 as well, but it seems like the junction command has been retired in Windows 10.

What's the correct way to make symbolic links in Windows 10?

4
  • 15
    What’s wrong with mklink?
    – Daniel B
    Jan 2, 2016 at 12:35
  • Anyone has good or bad info about junctions within (corporate) roaming profiles? (i.e.) trouble lurking...
    – Frank N
    Jan 13, 2020 at 8:41
  • 1
    The link is (effectively) broken: "The Unofficial Dropbox Wiki is no longer available." Mar 2, 2020 at 22:12
  • @PeterMortensen Fi've edited to put webarchive of the link to have more context at that time.
    – 4wk_
    Jan 4 at 14:55

6 Answers 6

162

It seems like the junction command has been retired in Windows 10.

You can download junction from Windows SysInternals (which is part of Microsoft):

Junction not only allows you to create NTFS junctions, it allows you to see if files or directories are actually reparse points. Reparse points are the mechanism on which NTFS junctions are based, and they are used by Windows' Remote Storage Service (RSS), as well as volume mount points.

Please read this Microsoft KB article for tips on using junctions.

Note that Windows does not support junctions to directories on remote shares.


So how do I create junctions or directory symbolic links in Windows 10?

Download junction as instructed above.

Now you can use the following commands.

Create a junction:

junction "C:\Documents and Settings\UserName\My Documents\My Dropbox\My Games" "C:\Documents and Settings\UserName\My Documents\My Games"

Create a directory symbolic link:

mklink /D "C:\Documents and Settings\UserName\My Documents\My Dropbox\My Games" "C:\Documents and Settings\UserName\My Documents\My Games"

You can use either mklink /j or junction in Windows 10 to create junctions.

You can use mklink /d in Windows 10 to create directory symbolic links.

Notes:

  • junction can also list junctions and determine if a file is a junction unlike mklink.

  • mklink is an internal command only available within a cmd shell.

  • By default Administrator privileges are required to create symbolic links.

    It can also be granted to other users. The security setting "Create symbolic links" can be granted at:

      Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\
    

Examples

Using mklink to create a directory symbolic link:

F:\test>mklink /d test-dir-sym-link test
symbolic link created for test-dir-sym-link <<===>> test

Using mklink to create a junction:

F:\test>mklink /j test-junction test
Junction created for test-junction <<===>> test

Using junction to create a junction:

F:\test>C:\apps\NirSoft\SysinternalsSuite\junction.exe test-junction test

Junction v1.06 - Windows junction creator and reparse point viewer
Copyright (C) 2000-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

Created: F:\test\test-junction
Targetted at: F:\test\test

Further Reading

6
  • 2
    Is this different to mklink /j?
    – Jonno
    Jan 2, 2016 at 15:51
  • 2
    @Jonno As far as I know it is the same when creating junctions. junction will also list junctions unlike mklink
    – DavidPostill
    Jan 4, 2016 at 9:31
  • 4
    As far as I can tell, you cannot use mklink inside PowerShell, so you must use cmd.exe. Also, you have to run it as Administrator. But don't take my word for it. I've been using a Windows computer for only about 40 hours. Jan 5, 2016 at 18:52
  • 1
    @BrunoBronosky Correct. That is because mklink is an internal command only available within a cmd shell. Note some cmd internal commands have been implemented in PowerShell, for example dir.
    – DavidPostill
    Jan 5, 2016 at 19:12
  • @BrunoBronosky By default Administrator privileges are required. It can also be granted to other users: The security setting 'Create symbolic links' can be granted at: Configuration\Windows Settings\Security Settings\Local Policies\User Rights Assignment\
    – DavidPostill
    Jan 5, 2016 at 19:13
74

Open a PowerShell session as elevated administrator and type:

New-Item -ItemType SymbolicLink -Path E:\Data\MyGames -Target "C:\users\UserName\MyGames"

or using less verbose syntax:

ni E:\Data\MyGames -i SymbolicLink -ta "C:\users\UserName\MyGames" 

Surely in 2016 and with Windows 10 you don't want to fiddle around with cmd commands or external downloads.

Windows 10 comes with PowerShell 5 which has builtin support for creating symbolic links.

7
  • 11
    Surely in 2016, I should not have to jump through hoops to create symlinks! Still one of windows biggest fails.
    – David Arno
    Dec 2, 2016 at 20:30
  • 22
    You're joking, right? I'd much rather do "mklink /d test-dir-sym-link test" than "New-Item -ItemType SymbolicLink -Path E:\Data\MyGames -Target "C:\users\UserName\MyGames". The super-verbose PowerShell syntax isn't really to my liking... Dec 13, 2016 at 12:00
  • 10
    @JaimedelosHoyosM - using shorter PowerShell syntax you can use ni test-dir-sym-link -i SymbolicLink -ta test May 6, 2017 at 10:29
  • Is there a way to create a SymbolicLink from the PowerShell like this without administrator privileges?
    – cjsimon
    Jun 12, 2018 at 23:38
  • 6
    @scape - you can use the first few letters of a parameter name if they they uniquely identify the paramter, e.g. -i are enough for -ItemType but -t is not enough because there are more than one parameter that start with t, so we need to use -ta Jan 24, 2019 at 16:46
24

If you want a GUI Tool for making/editing that symlinks use http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html

Link Shell Extension (LSE) provides for the creation of Hardlinks , Junctions , Volume Mountpoints , and Windows7/8's Symbolic Links, (herein referred to collectively as Links) a folder cloning process that utilises Hardlinks or Symbolic Links and a copy process taking care of Junctions, Symbolic Links, and Hardlinks. LSE, as its name implies is implemented as a Shell extension and is accessed from Windows Explorer, or similar file/folder managers. The extension allows the user to select one or many files or folders, then using the mouse, complete the creation of the required Links - Hardlinks, Junctions or Symbolic Links or in the case of folders to create Clones consisting of Hard or Symbolic Links. LSE is supported on all Windows versions that support NTFS version 5.0 or later, including Windows XP64 and Windows7/8/10. Hardlinks, Junctions and Symbolic Links are NOT supported on FAT file systems, and nor is the Cloning and Smart Copy process supported on FAT file systems.

enter image description here

2
  • 4
    Please read How do I recommend software for some tips as to how you should go about recommending software. You should provide at least a link, some additional information about the software itself, and how it can be used to solve the problem in the question.
    – DavidPostill
    Oct 24, 2016 at 15:59
  • 2
    It's a nice tool, but some more information in the answer would be nice.
    – DavidPostill
    Oct 24, 2016 at 16:00
2

If you have Windows 10 build 14972 (December 2016) or higher:

https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10

you can enable developer mode:

https://howtogeek.com/292914/what-is-developer-mode-in-windows-10

then use mklink without admin. Alternatively, PowerShell 6.2.0 (March 2019) or higher allow Symlink without admin:

New-Item -ItemType SymbolicLink -Path new.txt -Target old.txt
2
  • 1
    Upvote. Though the PowerShell SymbolicLink solution repeats a highly-voted answer from 2016, it finally makes clear that the target means the old file which gets a SymLink in the new file. Aug 18, 2021 at 17:06
  • "without admin" is correct except when using "/D" switch. Dec 13, 2021 at 10:46
1

There is an open-source tool called SymlinkCreator that provides a minimal UI for drag-n-drop both files and folders to be symlinked. It can use both relative paths (if in the same drive) or absolute paths for symlinking. There is an option to retain the script used for symlinking.

enter image description here

Disclaimer: I am the author of SymlinkCreator. I created it for my personal use but then shared it with everyone.

1
  • Please do not post the same answer to multiple questions. If the same information really answers both questions, then one question (usually the newer one) should be closed as a duplicate of the other. You can indicate this by voting to close it as a duplicate or, if you don't have enough reputation for that, raise a flag to indicate that it's a duplicate. Otherwise tailor your answer to this question and don't just paste the same answer in multiple places.
    – DavidPostill
    Apr 1, 2021 at 21:08
-1

There isn't any need to install anything!

There exists a simple and open-source symlink_creator.bat file.

  • Drag & Drop desired file/folder onto that file.

  • It's open-source (see instructions), so, just Right click >Edit on file to see its content (only several lines) yourself. No extra .exe or .dll files need to be installed.

Batch File

::  ================================================================== ::
::  ========================  Puvox.Software  ======================== ::
::  ================================================================== ::
::  ============== Symlink Creator with Drag&Drop v1.3 =============== ::
::  This script makes a symlink of any files/folders  ( ) 
::  ================================================================== ::
::  ================================================================== ::

@echo off
setlocal enableextensions enabledelayedexpansion

if "%~1"=="" ( mshta "javascript:alert('You should drag desired files onto this');close();" && exit )

set /P inputed_target_dir= Path to folder, wherein the symlink will be created:
set inputed_target_dir=%inputed_target_dir%\
set type=0

for %%a in (%*) do  (

rem  in PARENTHESIS we use ! instead % for set-ed variables  (read more: https://superuser.com/a/78509/249349 )
set original_path=%%a
set original_path_quoted=!original_path!
rem  Make it quoted (if it's not already quoted)
set original_path_quoted|find """" >nul || set original_path_quoted="!original_path!"

set isDirectory=no
:: if directory
FOR %%i IN (!original_path_quoted!) DO IF EXIST %%~si\NUL (
    set isDirectory=yes
    for /D %%i in (!original_path_quoted!) do SET original_drive=%%~di
    for /D %%i in (!original_path_quoted!) do SET original_dir=!original_drive!%%~pi
    for /f "delims=" %%i in (!original_path_quoted!) do SET original_basename=%%~ni
)

:: if file
FOR %%i IN (!original_path_quoted!) DO IF NOT EXIST %%~si\NUL (
    set isDirectory=no
    for /f "delims=" %%i in (!original_path_quoted!) do SET original_drive=%%~di
    for /f "delims=" %%i in (!original_path_quoted!) do SET original_dir=!original_drive!%%~pi
    for /f "delims=" %%i in (!original_path_quoted!) do SET original_basenameWithExt=%%~nxi
)


for /D %%i in ("%inputed_target_dir%") do SET target_drive=%%~di
for /D %%i in ("%inputed_target_dir%") do SET target_dir=!target_drive!%%~pi
  
set isSameDrive=1
IF /I "!original_drive!"=="!target_drive!" (  set isSameDrive=2 )

:: if same ditectories, then use prefix name
set prefix=
IF /I "!original_dir!"=="!target_dir!" ( set prefix=_symlinked_ )

if !type! LSS 1 (
    rem ::   If same drives, then allow user to choose HARD method. Otherwise, only SOFT can be used
    set type=2

    rem ::   DONT USE   "!isSameDrive!"=="yes"  comaprison, as it has issue  
    if /i !isSameDrive! GTR 2 ( set /P type= Seems source and Destinaton drives are same, so you have an opportunity to create HARD-SYMLINK [press 1], otherwise press ENTER and the default SOFT-SYMLINK will be created : )
)

:: if directory
if !isDirectory!==yes (
    FOR %%i IN (!original_path_quoted!) DO IF EXIST %%~si\NUL (
        IF "!type!"=="1" ( 
          mklink /J "!target_dir!\!prefix!!original_basename!" !original_path_quoted!
        ) ELSE ( 
          mklink /D "!target_dir!\!prefix!!original_basename!" !original_path_quoted!
        )
    )
)

:: if file
if !isDirectory!==no (
    FOR %%i IN (!original_path_quoted!) DO IF NOT EXIST %%~si\NUL (
        IF "!type!"=="1" ( 
          mklink /H "!target_dir!\!prefix!!original_basenameWithExt!" !original_path_quoted!
        ) ELSE ( 
          mklink "!target_dir!\!prefix!!original_basenameWithExt!" !original_path_quoted!
        )
    )
)


)
:: FOR loop


:: mshta "javascript:alert('error: creating Hard-Symlink for different drives has failed');close();"
mshta "javascript:alert('Finished');close();"
endlocal
5
  • 11
    You should add in your answer how exactly this batch file works and what your association with it is. Batch files can be very destructive and running random ones from the internet goes against common sense.
    – user487867
    Mar 19, 2018 at 13:45
  • 2
    The answer above has already had a moderator comment on it. I was mainly concerned with your answer because that website you linked looks somewhat sketchy, and the format of your answer triggered some red flags for me. I'm just being paranoid really.
    – user487867
    Mar 19, 2018 at 14:58
  • 1
    unfortunately, it finishes with an error "syntax is incorrect"
    – tutejszy
    Sep 17, 2019 at 11:25
  • 1
    @T.Todua .... I just edited to add the actual content of the batch file too in case the link breaks again, the logic itself is available. Mar 3, 2020 at 12:04
  • Can you run Javascript straight from CMD, without using electron, Node or react Native curious about the line containing => mshta
    – Ryan Stone
    Oct 13, 2020 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.