Mounting persistent network share on a Windows Server at startup


Windows Services launches by Windows Service Control Manager (SCM) are launched upon Windows OS startup prior to a user log-in. This can cause mounted drives or UNC path to fail to authenticate and therefore not mount before the service starts causing file not found errors. Browsing a network shared after a user log-in will continue to work as the share once authenticated inside a Windows user session, will have credentials saved. But Windows services will not see it even if they are restarted a the SCM has  been launched prior to network share login step.


The below solution is based on mounting a drive letter. In theory, this could also be made to work with a UNC path, provided the credentials are available at startup of the Windows OS.

If you need to configure a network share as a drive letter mounted volume on a Windows Server, it can be done. The key here is to ensure the drive letter is available before services started by Windows Service Control Manager (SCM) need it. Also, this drive has to be unmounted before shutdown. Here is a recipe tried and tested by our support team:

  1. Create two batch files, one with a command to mount the network share and another to remove it. For example mount.bat and unmount.bat

    The command invoked in the script to mount as Z drive: net use z: \\essan.evolphinpoc\ES_SAN /user:Administrator Password /persistent:yes

    Please ensure the user name/password credentials allow read or write to the share from a Windows machine. Also, please ensure that a path is specified after the remote machine name/IP address. The mount is only created on a path to a folder.

  2. Similarly, unmount.bat will have the script to remove the drive.
  3. Add the .bat files to a Windows Task set up to run at startup and shutdown respectively, using the “Create Task” menu option:

  4. Note instead of using the task scheduler, customers have also successfully used Group Policy editor to launch at startup/shutdown. This might be more robust than the task scheduler recipe above.

  5. Specify the full path to your batch file in the task action (“Start a program”).

  6. Configure the tasks to run at Windows startup without any logged-in user:

  7. Run the batch scripts to ensure that the drive letter gets mounted and unmounted as desired.
  8. Or you can also, import the task from a preconfigured XML file click here to download the sample file. Please edit the file as follows:
    1. Rename the file to mount.xml type from mount.txt.
    2. Change batch file path “C:\Users\John\Desktop\mount.bat” to batch file path specific to your system.
    3. Change the author tag “VANTAGE-RACK\John”.
    4. Change the description tag if you want to.
  9. Finally, reboot the Windows Server to allow the task to mount the share as a drive letter.
    You will notice that the mounted drive-letter shows as a “Disconnected” network drive in windows explorer. This seems to be just a Windows annoyance. The drive will still be accessible by all users.

Leave a Comment