Windows – Run exe from network share, with/without admin privileges

network-sharesnetworkingpermissionsuacwindows 7

I'm trying to run a Win7 exe that's on a network share (a Linux CIFS server). The share was created by a non-admin (see Windows 7 problem to access shared folder). I can read and edit and write files in the folder containing the exe. I can read (i.e., copy) the exe.

But when I try to run the exe, either by double-clicking and OK'ing the UAC dialog, or by right-clicking "Run as administrator", I get:

Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.

Must I copy the exe to local disk before I can run it?

I followed the recipe at the (not yet accepted answer for) How can I run an EXE from a Network Share?, but that appears to grant only read permissions, not exe permissions.

(Distantly related: Cannot Run .exe from Network Drive.)

Best Answer

This is expected (although unusual) behaviour.

When you run a program from a network share, it can be done in a few ways.

  1. The share is mapped to a network drive: for example g: -> \\server\share
  2. The share is accessed directly by the share: \\server\share

The first one can already cause a problem when you run a program as Administrator and I'll explain this below.

What happens when I run a program as administrator?

When you run a program as administrator, a new environment is created and the profile for Administrator is loaded. Although it will use the rights your user has, it obviously has additional rights for the administrator user. As a concequence, any mapping to a network drive are not created, and thus your Administrator user does not have any additional network mappings present in its profile, thus the g: does not exists.

It is even possible if the security settings on the share are very tight, the administrator user does not have permission either.

How to troubleshoot and overcome the problem?

Obviously you can just copy the file locally and run it then, but lets assume you don't want to do this.

You can start a command prompt as administrator first. From there enter the following command:

net use g: \\server\share

Replace the drive and share so they match your existing share.

As long as this command prompt window is open, you can execute your executable as administrator and it will work guaranteed.

If your user does not have rights to the \\server\share, net use will fail with an error telling you exactly this, so you know where this problem is.

If the rights are good, you can alternatively access the executable by going to \\server\share and run the executable as administrator. This eliminates the requirement for having a network share first in a different environment.

Related Question