In order for network shares to be mapped into drives and accessible within Windows services, you need to login as the NT AUTHORITY\SYSTEM account.

To do this, download the Sysinternals Suite from Microsoft, and unzip it to a directory, say C:\TEMP

The following steps assume that you've unzipped SysInternals to C:\TEMP and all the executables are in there.

  1. Launch a command prompt with as Administrator.
  2. CD \TEMP
  3. psexec -i -s cmd.exe
    This launches a new window, and step 4 should be performed in that new window.
  4. net use Z: \\servername\sharedfolder /u:username /persistent:yes
  5. Create a script that runs on computer startup that has only line 4 in it acccording to Microsoft's article: Assign Computer Startup scripts.

If you need to remove it,

  1. Launch a command prompt with as Administrator.
  2. CD \temp
  3. psexec -i -s cmd.exe
    This launches a new window. Step 4 should be entered in that window.
  4. net use Z: /delete