As a rule of thumb Windows services can't access mapped drives and you have to use UNC paths instead.

I'm convinced that there's a way around this so that a Windows service can access a mapped drive but I can't find it anywhere.

My specific case is that I'm running Tomcat7 on a Windows 2008 server.

  • It's not something I've done before but I'm sure I've seen that it can be done – Edd Sep 25 '13 at 9:57

An alternative to using mapped directories or UNC paths is to use symlinks.

NTFS symbolic links (symlinks) can refer to a UNC path but differ from shortcuts in that there is no redirect to the requested location. If you create a symlink as the following...

mklink /D C:\myLink \\\c$

... then when you open C:\myLink the address of the folder you are in will be C:\myLink and not \\\c$, which is what you would get if myLink was a shortcut and not a symlink. This is significant if your application has compatibility issues with UNC paths.

Additionally the symlink exists in the filesystem and does not need to be recreated after logon as your average mapped drive requires (generally automated) and is therefore available to Windows services.

| improve this answer | |
  • 3
    Little info from my experience, the command only works in Windows Command Prompt and not in Power Shell – Muffun Jun 8 '16 at 15:52
  • That's wild.... and very useful. – Marki Apr 30 '19 at 14:06

I've found a solution to this problem that seems to be working nicely: https://stackoverflow.com/a/7867064/669645

Steps that I took:

  1. Create a bat file which contains the command net use z: \servername\sharedfolder /persistent:yes
  2. Create a scheduled task
    • Set user as "System"
    • Add an action to run the bat file
  3. Manually run the task (no need to set a schedule)

Note: the drive will appear as "Disconnected Network Drive (Z:)" but will still be accessible to all logged in users and also windows services

| improve this answer | |
  • This isn't actually working for me as the mapped drive isn't persisting after a reboot (fine on Windows 7 but not Windows Server 2008). If I schedule the task to run on startup I still can't see the mapped drive – Edd Sep 25 '13 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.