The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation

Q&A: Can my Legacy Application Read Network Drives when Run as a Service?

Q & A - Accessing Network Shares from Windows Services
  I am evaluating AlwaysUp. I have a legacy application which must run as a local user. I can get it to run as a service using AlwaysUp.

The application works with parameters. These point to a domain folder (eg. \\MyServer\Data1\). There is an obvious contradiction on one hand, running an application as a local machine user, and on the other hand, trying to access a domain folder. Wondering if there is any way AlwaysUp can accommodate this?

I have mapped a drive from the local user to the network folder and cached credentials. This works. Only problem is cached credentials sometimes expire.

— David

Hi David.

Since your application must run as a local user, you should specify the account on AlwaysUp’s Logon tab:

Enter your Windows account on the Logon tab

Please enter the username and password for a user that has logged in and run your application successfully — likely the account you are logged into now.

With that account in place, AlwaysUp will run your legacy application in the context of that user. Your program will be able to read from and write to any files that the account has permission to access.

However, as you point out, using drive letters can be tricky. Beyond cached/saved credentials, drive mappings may not be automatically applied when you login as a service. For example, that “P” drive you see in Windows Explorer may not be available to your program running as a Windows Service.

Fortunately, AlwaysUp can usually re-create your drive mappings. Check the Attempt to automatically reconnect all network drives option on the Extras tab to enable that feature:

Automatically reconnect network drives

But as the text implies, automatically reconnecting doesn’t work in all situations. Sometimes a password is required.

To totally sidestep the issues of drive letters when running as a service, we recommend using UNC paths instead of mapped drives whenever possible. Since your account has permissions to the underlying resource, that shouldn’t pose a problem.

Will your application accept a UNC path? Please test to find out.

Troubleshooting network/mapped drives (and other issues)

By the way, launching the command line interactively as a Windows Service through AlwaysUp will give you the opportunity to experiment with your application as a service.

For example, you can try to:

  • Change the directory (CD) to the UNC path and confirm that the files are accessible

  • Run the full command to launch your legacy application with UNC path parameters. If it fails, you may have a permissions issue. Look to your application’s log files for clues.

Best of luck with your legacy program/service! Please get in touch if you have any other questions.

Posted in AlwaysUp | Tagged , , , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *