19

With Windows 8, why isn't a mapped drive available under an elevated cmd prompt but is under a regular cmd prompt? I can run a net use and get it to be available but I still find this odd.

Jon
  • 9,181
  • 39
  • 95
  • 127
JimDel
  • 1,964
  • 11
  • 33
  • 48

3 Answers3

23

When using UAC with an administrative user, at login, Windows creates two tokens. One token (the elevated one) is unfiltered, and has the Administrators group enabled. The other token has the Administrators group (and some other details, like the Power Users group) filtered out.

Since these two tokens have separate security contexts, network connections in one aren't available in the other, even if it's really the same user.

So if you map a drive using Explorer, an elevated Command Prompt (or any other elevated process) won't be able to see it.

You can map the same network resource (using the same drive letter, even) in your elevated Command Prompt using the NET USE command. After that, any elevated process will also be able to see it.

William
  • 859
  • 7
  • 14
  • 1
    Is there a way to use Explorer AND have the drive be visible to all users? – JimDel Oct 09 '12 at 14:19
  • 4
    `net use e: \\computerName\folder password /user:domain\username /p:yes` is the commanded I ended up using that made it work. (Where `e:` is the drive letter you are mapping, `\\computername\folder` is the path to be mapped, and `password`, `domain` and `username` are the normal credentials to log-in. Hope that helps someone. I followed on example from here http://pcsupport.about.com/od/commandlinereference/p/net-use-command.htm – phyatt Mar 27 '13 at 23:15
  • @phyatt Is this safe for Windows10? – GreenAsJade Jul 20 '16 at 06:06
  • Safe/secure is a whole other topic. It should have the same behavior on 10 as it does on 8. – phyatt Jul 20 '16 at 13:03
19

William's answer explains why this happens and provides one workaround. But I want to add there is actually a registry fix from Vista that works in Windows 7 to adjust this behavior. Just add this to your registry:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"EnableLinkedConnections"=dword:00000001

After a reboot mapped drives should be accessible through the elevated command prompt.

Craig W
  • 721
  • 1
  • 7
  • 10
  • I had not known this was possible. Excellent. Technet has a reference - http://technet.microsoft.com/en-us/library/ee844140(v=ws.10).aspx – William Oct 02 '14 at 15:50
3

Because you're elevating the command prompt as a different user, and the mapped drive in question was mapped by the non-administrative user. Different users have different user settings, like printers, mapped network drives and so on.

HopelessN00b
  • 1,882
  • 3
  • 21
  • 29