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:
- Create two
batchfiles, one with a command to mount the network share and another to remove it. For example
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.
unmount.batwill have the script to remove the drive.
- Add the .bat files to a Windows Task set up to run at startup and shutdown respectively, using the “
Create Task” menu option:
- 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.
- Specify the full path to your batch file in the task action (“Start a program”).
- Configure the tasks to run at Windows startup without any logged-in user:
- Run the batch scripts to ensure that the drive letter gets mounted and unmounted as desired.
- Or you can also,
import the task from a preconfigured XML fileclick here to download the sample file. Please edit the file as follows:
- Rename the file to mount.xml type from mount.txt.
- Change batch file path “C:\Users\John\Desktop\mount.bat” to batch file path specific to your system.
- Change the author tag “VANTAGE-RACK\John”.
- Change the description tag if you want to.
- 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.