Windows Server 2008 R2 – Mapped Shares Not Showing in Command Line

network-shareuacwindows-server-2008-r2

When I map a shared folder to a drive in Explorer in Windows Server 2008 R2 the new drive letter (say Z:) does not work in cmd.exe (started as administrator).

What am I doing wrong?

I believe this only happens on systems where UAC is active.

Best Answer

You should map the drive from within your administrative CMD session instead, as it is using a different user context (the one of the administrative user obviously) and thus has no access to the environment of your "regular" user. From http://msdn.microsoft.com/en-us/library/windows/desktop/ms685143(v=vs.85).aspx :

Drive letters are not global to the system. Each logon session receives its own set of drive letters from A to Z. Therefore, redirected drives cannot be shared between processes running under different user accounts. Moreover, a service (or any process running within its own logon session) cannot access the drive letters that were established within a different logon session.

Just issue

net use z: \\server\unc\path

to establish the mapping in your cmd session before executing whatever you want to be done with it.