Windows – Map network drive for the SYSTEM user in Windows

network-sharesshared-folderswindows

I have a piece of software which needs access to files as if they are local to the machine, so I just mapped the network drive as a letter using net use. This works as expected, however the software itself runs as a service with the SYSTEM user account, this is not optional nor configurable. I currently have the drive mapped in the user from which I executed the net use.

So my question is, how do I map a drive so the SYSTEM account has access to it?

As pointed out in this question there is no way for mapping a drive for all users.

An in more general case how do you mount a remote location into the local file system for the whole system (at boot time is perfectly ok), in the same fashion as is done in Linux.

Best Answer

Simple solution through cmd (Administrator privileges) without any batch files would be:

schtasks /create /tn "my_mount" /tr "net use V: \\hostname\directory /persistent:yes" /sc onstart /RU SYSTEM

followed by a restart of your server or by executing:

schtasks /run /tn "my_mount"

EDIT:
User alfa_989 suggests the following command extension, which I haven't tested.
But it still might be helpful for somebody:

schtasks /create /tn "my_mount" /tr "net use V: \\hostname\directory /persistent:yes" /sc onstart /RU SYSTEM /RL HIGHEST
Related Question