Tuesday 19 March 2019

command line - Why isn't a mapped drive available under an elevated cmd prompt but is under a regular cmd prompt?



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.



Answer



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.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...