-1

After a successful compiled application, I transferred the executable to a network drive with the post-build event in VS. Every time I start my project, it is opened under my user credential but it needs administrators privilege to run like expected. So VS ask me if I want to close VS and restart it under admin privilege. After that, VS looses my connected network drives because it runs under administrator, not my own credential. If I go in command prompt with admin privilege and type "Net Use" command, there is no network drives attached. After mapping the missing drives, VS is able to compile like expected.

Now, my question is, when I go to command prompt with admin privilege, what is my credential? If I type "whoami", I get my own user name but it is not totally true because there is no mapped network drives like under command prompt without admin privilege. Even if my user is under local administrators group...

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
Guibson
  • 11
  • 2
  • 1
    Mapped network drives aren't per-user, they are per-logon-session. For example, if you are logged into two simultaneous sessions on a Remote Desktop server, each session has its own set of mapped network drives. The same applies with UAC, the limited token and the elevated token are in different logon sessions and so have their own set of mapped drives. – Harry Johnston Jun 23 '15 at 21:29
  • Thanks Harry. With your help, I found a work around. We can add a value in the registry to synchronize mapped network drives between tokens. See here the howto : https://technet.microsoft.com/fr-ca/library/ee844140(v=WS.10).aspx – Guibson Jun 26 '15 at 14:22

1 Answers1

1

We can add a value in the registry to synchronize mapped network drives between linked tokens. This is documented under Some Programs Cannot Access Network Locations When UAC Is Enabled in TechNet:

To work around this problem, configure the EnableLinkedConnections registry value.

The registry key is

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System

The EnableLinkedConnections value is a DWORD set to 1 to share mapped drives between linked tokens or to 0 for the default behaviour.

Harry Johnston
  • 35,639
  • 6
  • 68
  • 158
Guibson
  • 11
  • 2
  • Good work - I was aware of the original hotfix that provided that functionality (on Windows 7) but was never sure whether it had been included in service pack 1 or in later versions of Windows. (Bit of a shame it isn't on by default, really!) For the record, note that this only affects UAC linked tokens - multiple logon sessions will still have separate drive mappings, and I suspect runas won't be affected either. – Harry Johnston Jun 26 '15 at 22:05