0

When the application is executed with run as administrator it fails to find files on a mapped network drive using FindFirstFile. If the executable is run without run as administrator is works. The user is a local administrator on the PC. When FindFirstFile fails the error is 3, ERROR_PATH_NOT_FOUND. Is running as an administrator changing access rights or my access to the mapped drive?

I'm testing on a Windows 10 PC with a domain user that is a local administrator. Application was built using VS 2010 on the Windows 10 PC. Application is a native c++ app. I've turned off the firewall, still fails. Turned off Windows Defender, still fails. Recreated share and mapping, still fails. Ideas?

Fro
  • 3
  • 1
  • 4
  • 1
    Are you running the application as Administrator (either by right-click -> run as Administrator or by checking the run as Administrator box in the file's properties)? – Miles Budnek Feb 17 '16 at 00:16
  • My immediate response was to reply with yes but I decided to double check and found I have a different issue. The problem is with run as administrator. Whenever I run as administrator I get the UAC notice and click on Yes then it fails to find the mapped drive. If I run as the normal user which happens to be an administrator it works. Is run as administrator changing my access rights or specific access to the mapped drive? I'll edit the original question. – Fro Feb 17 '16 at 15:41
  • Drive letter mappings are a per-user settings. And yes, if you elevated to acquire admin rights then you are a different user. With no drive mappings by default. – Hans Passant Feb 17 '16 at 15:52
  • So did this change with Windows 10 because it does not work that way in Windows 7. – Fro Feb 17 '16 at 19:34
  • It worked the same way in Win7. UAC has changed a bit since then though, and your UAC settings could affect how elevated processes do their thing. – Miles Budnek Feb 17 '16 at 19:38
  • On Windows 10 PC UAC is set to off and it fails using run as administrator. In Windows 7 UAC is set to off and it works fine. Something has changed or there are other settings that need to be changed. – Fro Feb 17 '16 at 19:54
  • OK I remembered a change. Quite a while ago on the Windows 7 PC I had to enable the registry setting EnableLinkedConnections to fix a problem, probably something similar. I tried this on the Windows 10 PC and the problem is fixed. Memory problem on my part. – Fro Feb 17 '16 at 20:17

1 Answers1

0

Network drives are mapped per-user. If you map a drive as your user, but run your application as Administrator, the network drive won't be mapped from the application's perspective. To get around this, you can map the drive as Administrator by opening an admin command prompt (right-click cmd -> run as Administrator) and run net use F: \\path\to\my\share.

Miles Budnek
  • 28,216
  • 2
  • 35
  • 52
  • My fix was to enable the registry setting, EnableLinkedConnections. This allowed everything to work. – Fro Feb 17 '16 at 20:18