Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
    
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
up vote 2 down vote accepted

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 \\127.0.0.1\c$

... then when you open C:\myLink the address of the folder you are in will be C:\myLink and not \\127.0.0.1\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.

share|improve this answer
1  
Little info from my experience, the command only works in Windows Command Prompt and not in Power Shell – Muffun Jun 8 at 15:52

I've found a solution to this problem that seems to be working nicely: http://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

share|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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .