1

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.

Andrew J. Brehm
  • 1,611
  • 7
  • 37
  • 57
  • 1
    Obviously the drive is mapped into the security context in 2008 R2, so it's not like XP. If you want to mount a drive, for a user working on a Windows 2008 R2 Terminal, you need to map the drives using his account, otherwise the drive map will be isolated from him. – Andrew Smith Jul 17 '12 at 08:01
  • That statement doesn't make sense to me. What does it have to do with XP? How does a terminal come in? And who is "he" in "his account"? – Andrew J. Brehm Jul 17 '12 at 16:34

1 Answers1

6

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.

the-wabbit
  • 40,737
  • 13
  • 111
  • 174
  • I thought UAC was the same user context but running with full permissions rather than restricted. – Andrew J. Brehm Jul 17 '12 at 16:33
  • @AndrewJ.Brehm You are using the same user for elevation (i.e. the user you are running with is the same user context but with privileges stripped)? In this case, you have the same user name, but a different account token and a different logon ID, which basically results in the same problem - see http://support.microsoft.com/kb/937624/en-us. You could set EnableLinkedConnections as described in the article to let LSA re-create your mappings in the elevated session, but mind that it this feature is marked as "unsupported". – the-wabbit Jul 18 '12 at 10:15