65

I am not sure but when I start my Command Prompt in Administrator mode, I can't switch to a mapped drive. I can do so if I am not in Administrator mode.

Am I missing something simple?

AngryHacker
  • 18,217
  • 67
  • 156
  • 209

3 Answers3

71

When you start a command prompt "As Administrator" it's running in a different user context than when you don't.

Since mapped drives are user-centric, that Admin user context will not have the (same) drives, and you'll have to map them for that user context once the command window is open as Adminsitrator, e.g. by running net use <letter>: \\<server>\<share>. An example:

net use Z: \\SuperServer\SuperShare

Also, you can enable the EnableLinkedConnections flag in the registry to cause the session token to be shared:

To work around this problem, configure the EnableLinkedConnections registry value. This value enables Windows Vista and Windows 7 to share network connections between the filtered access token and the full administrator access token for a member of the Administrators group.

To do this, set the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLinkedConnections DWORD flag to 1, and then reboot your machine.

For more info on that from Microsoft, see: Some Programs Cannot Access Network Locations When UAC Is Enabled

Kenny Evitt
  • 395
  • 4
  • 16
Ƭᴇcʜιᴇ007
  • 111,883
  • 19
  • 201
  • 268
16

This makes me think about an old Windows Vista reported issue.

Can you try:

  1. Open RegEdit
  2. Go to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  3. Create a DWORD value named EnableLinkedConnections and set it to 1
  4. Reboot the computer
  5. Test again
nixda
  • 26,823
  • 17
  • 108
  • 156
user2196728
  • 1,306
  • 9
  • 10
10

One other work-around that took me ages to find is to run net use from a scheduled task as the NT AUTHORITY\SYSTEM account. Apparently drives mapped under this account show up for all users and all elevation levels.

I've tested this and it works even on NFS shares (which can be a bit finicky). Just create a scheduled task set to run at system startup, and specify the following command:

net use \\server\share Z: /persistent:no

It might possibly work to run it just once with /persistent:yes, but I haven't tried that. Granted, "just map it again" works too, but that drive still won't be visible to scheduled tasks running in different contexts. The downside is that all real users see it too, so not so good for multiuser setups.

RomanSt
  • 9,553
  • 15
  • 56
  • 74
  • could you add about the method you use to open cmd as "NT Authority\SYSTEM"? I heard that psexec from sysinternals can do that, is that what you are using? And I recall something about task scheduler being able to do it.. maybe you can elaborate? – barlop Jun 19 '22 at 19:04
  • @barlop I don't open cmd under that user account; I just create a Scheduled Task and the user account is one of the settings on the General tab. – RomanSt Jun 24 '22 at 18:56
  • @barlop [How to run command as `NT AUTHORITY\SYSTEM`](https://superuser.com/a/1709857/) – ᄂ ᄀ Apr 24 '23 at 07:12
  • The order of arguments is mixed in your example. It should be `net use Z: \\server\share /persistent:no`. In other words, drive letter should come first after `net use`. – Roland Pihlakas Aug 16 '23 at 18:59