When you run an elevated command prompt as administrator, the mapped drives are unavailable in the elevated command prompt.
This issue also affects other applications that run in an elevated context (run as administrator) and use drive letters to access mapped drives.
When UAC is enabled, the system creates two logon sessions at user logon. Both logon sessions are linked to one another. One session represents the user during an elevated session, and the other session where you run under least user rights.
When drive mappings are created, the system creates symbolic link objects (DosDevices) that associate the drive letters to the UNC paths. These objects are specific for a logon session and are not shared between logon sessions.
EnableLinkedConnections registry entry forces the symbolic links to be written to both linked logon sessions that are created, when UAC is enabled.
When the UAC policy is configured to Prompt for credentials, a new logon session is created in addition to the existing two linked logon sessions. Previously created symbolic links that represent the drive mappings will be unavailable in the new logon session.
- In Local Group Policy Editor, locate the following Group Policy path:
Local Computer Policy\Windows Settings\Security Settings\Local Policies\Security Options
- Configure the following policy to Prompt for consent: User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode
- In Registry Editor, locate and then click the following registry subkey:
- Right-click Configuration, select New, and then select DWORD (32-bit) Value.
- Name the new registry entry as EnableLinkedConnections.
- Double-click the EnableLinkedConnections registry entry.
- In the Edit DWORD Value dialog box, type 1 in the Value data field, and then select OK.
- Exit Registry Editor, and then restart the computer.
You can use REG ADD to add the registry value via an elevated command line:
reg add HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLinkedConnections /t REG_DWORD /d 1 /f