I recently found the need for permanently mounted network shares on a Windows server. Not an obvious thing to do, unfortunately…
What do I mean by permanent? When mapping a share on Windows as a user, when that user logs off… the share will disconnect. For an installed Windows Service that requires access to defined network shares – this is unworkable. We need to create network shares that retain their connection no matter whether or not a particular user is logged on.
Why do I need to do this? For a server-based AIR project ;D
Took a lot of searching – but here is how to do it!
First, we need to get into the Windows Server Group Policy Editor. The simplest way to access this is to type “gpedit” into the start menu search. The Group Policy Editor will now appear.
Using the left navigation menu, drill down through
Computer Configuration >
Windows Settings >
Scripts (Startup/Shutdown). Double-click on Startup to open the Startup Properties dialog.
From the Scripts tab, we will want to click on the Show Files… button to open a File Explorer window.
Right-click in this window to create a new text file called mapping.bat (or whatever you want to call it). This needs to be a .bat file though to execute commands properly.
Edit the file and add the following lines of code:
net use m: \\servername\share
Add one command like this for each share you wish to add.
Now, return to the Startup Properties dialog and click Add… to browse to and select the .bat file we just created. It will appear in the list of startup scripts.
Exit the dialog by clicking OK.
You’ll now need to restart the server for this to take effect. This will allow the startup process to run the required commands to mount these network shares without any user being logged on.