Error 7: File Not Found when Accessing a Mapped Network Drive

Updated Oct 22, 2018

Issue Details

I am receiving Error 7: File Not Found when I try to open a file on a Mapped Network Drive using a static or programmatic file path.  

If I navigate to the file using the file dialog, the error no longer occurs, even if I use a static or programmatic file path.  When I restart my computer, the error returns.  Why is this happening?


The problem here is related to the functionality of Windows User Account Control, and the Run as Administrator option.  When User Account Control is on, and a user has administrator rights, the user actually has two accounts.  One account has normal user rights, and the other has administrator rights.  During normal operation, the user operates in the normal account, but when the Run as Administrator option is used, the processes for the program using this option are run in the administrator account.

This is normally not an issue, except in the case of mapped network drives.  As a security feature, Windows only allows mapped network drives to be accessed by the users that map them.  This becomes a problem when a program that is uses the Run as Administrator option needs to access a mapped network drive.  When the program looks for a specified file on the mapped network drive, it fails to find the file because in the administrator account, the drive it is referencing does not exist.

The reason that this error disappears when you navigate to the file using a file dialog is that by navigating to the network drive, you are implicitly mapping it for the administrator account.  Once this happens, the file can be found and the error will not be seen until the drive is unmapped, either by disconnecting from the network or restarting the computer.

Below is a KnowledgeBase article from Microsoft describing the issue in detail.  The article is written for Microsoft Vista, but the behavior is the same in Windows 7.  There is also a workaround described, but it is not supported by Microsoft as it may make your computer vulnerable.



Not Helpful