Wednesday, December 18, 2013

How to make elevated Windows programs recognize network drives

In Windows Vista or newer, if User Access Control (UAC) is enabled, network drives mapped while in a non-elevated state are not accessible to the same user in an elevated (administrator) state.

More detail in Microsoft articles here and here.

For example, after mapping a network drive, P:, from Windows Explorer (not elevated), I launch an elevated command prompt ("Run as administrator") and run the net use command. It shows the drive mapping exists, but rather than Status being OK, it is Unavailable.



Workarounds:
  • Map the drive twice: non-elevated and elevated. (E.g., launch an elevated command window and use the net use command.)
  • Set a registry setting that will force Windows to make the network drives available to both the standard and administrator accounts automatically:
    Create a new DWORD entry with the name HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System/EnableLinkedConnections and value 1.
    See articles here and here.
    Warning: This can cause problems; see this Microsoft hotfix.
  • Disable UAC.