How do I mount a network drive to a folder?
Solution 1
In Windows Vista or Windows 7, you can create a "junction folder"/"Symbolic link" to redirect the contents of one to another.
Simply type:
mklink /d "c:\data\network docs" "\\server\shareddata\"
I have not tested it with a FQDN, but as far as I can tell, it should work. I have tested it with a network mapped drive, and this works perfectly... so at a last resort, you can map first, then do this.
The /d
creates a directory (c:\data\network docs
in this example) and it must not exist. It will be created by this command.
You must have admin privileges when you run CMD. You can do this under an admin account by pressing ctrl-shift-enter instead of enter when you run CMD.
The end result is also achievable in Windows XP, but it is not as easy. Guide here
Solution 2
It runs ok for me:
net use \\\server\share\folder1\folder2
mklink /d "C:\Users\Admin\test\mi_enlace" \\\server\share\folder1\folder2
Solution 3
For PowerShell:
(Remember to run as Administrator!!!)
New-Item -ItemType SymbolicLink -Path "C:\Somewhere At SMB Client" -Target "\\SMB-SERVER\Somewhere"
And if you want to delete it, simply delete it in File Explorer. DO NOT CALL rm
OR del
in PowerShell, as it would delete all the files. Instead, cmd /c "rmdir C:\Somewhere At SMB Client"
or (Get-Item C:\Somewhere At SMB Client).Delete()
would do the trick.
Solution 4
This is an example fore the solution already provided by William Hilsum
open cmd
type: cd \folder-parent-of-the-folder-to-clone
type: deltree folder-to-clone (or you will get the following error: Cannot create a file when that file already exists)
type: mklink /d "folder-to-clone" "g:
\folder-to-clone"
The software will prompt: symbolic link created for folder-to-clone <<===>> g:\folder-to-clone
Related videos on Youtube
Toby Allen
Long Time Delphi Developer. Not Quite so Long PHP Developer. Laravel Developer. VBA Shark for a while. Once did some POP11, Lisp and Prolog. Once learned to enjoy Objective-C IPhone Development. Perforce Fan, now a bit of a Git. Any code I contribute to StackOverflow can be used by any person for any purpose. GitHub/tobya / @toflidium GitMySite/ DocTo
Updated on September 17, 2022Comments
-
Toby Allen over 1 year
Does anyone know of a third party (or even windows native) solution to this simple problem?
I want to map an internal network share on our windows server to a folder on each of the client machines in the network. I don't want to to use drive letters; I would just like to set up a folder on my
C:
drive that is actually a Windows share. For example,C:\Data\Network Docs
should actually point to\\Server\SharedData\
.Is this possible? Is there any tool that does it? All clients are using Windows XP and Windows 7.
-
Admin over 6 yearsplease update for windows 10 also
-
Admin over 5 yearsRelated: Mount Remote CIFS/SMB Share as a Folder not a Drive Letter on Server Fault.
-
-
Bill over 11 yearsNote that for Windows XP, the linked guide explicitly says, "you can’t create a junction point on an NTFS drive that points to a network drive." (for Windows XP)
-
Nick over 10 yearsAdding to @Bill's comment. You can't make a junction point in Win7, etc either, but the mklink tool functions like a symbolic link. If you try to use a junction (ie, using the Sysinternals junction tool), it will make the junction, but will not function.
-
dave k over 10 yearsWorks for Windows 8.1 as well. Make sure to run the command prompt with administrative privileges.
-
Cestarian about 8 yearsThis is a symbolic link, not a junction link, there is a difference.
-
Steve Hiner almost 8 yearsA shortcut can't be used like a normal folder so this won't work to do what they are requesting.
-
userJT over 6 yearswhat about win 10?
-
userJT over 6 yearswill this persist over months and years (reboots?) (I am currently using map network drive to letter but would prefer mapping to folder)
-
Ben Johnson about 6 years@Nick That is not true; one may absolutely make a junction point in Win 7, using
mklink
with the/j
switch. This is clear from the help output:mklink /?
That said, one may not make a junction (reparse) point from a local disk to a network resource; junctions work on local volumes only, which is why the\d
switch is required in this instance. -
Nick almost 6 years@BenJohnson yes - sorry to not be clear - I meant to say that you can't make junctions between local folders and network folders and you need to do a symlink instead.
-
still thinking about it almost 6 yearsPoint taken. I was still a beginner at that point! i needed to get some reputation points for a course i was doing.
-
Eryk Sun over 4 yearsPlease delete any mention of "junction". Mount points (i.e. junctions) are not allowed to target remote filesystems because they're defined to be evaluated on the server side, as opposed to symlinks, which get evaluated on the client side. In this way and other ways, mount points and symlinks do not behave the same and are not intended for the same use cases. Mount points are not legacy/outdated symlinks. They have a specific place in the overall scheme of things. Also, this answer should mention L2R (local to remote) symlink policy, which may disallow following symlinks with remote targets.
-
Mawg says reinstate Monica over 4 yearsCourses require S.E rep??!!
-
Simon Melhuish almost 3 yearsYou don't have to be an administrator if you create a link in a folder you control for a share you have access to - either with your own credentials, or after running
net use \\computer\share sharepass /user:shareuser
.