Service Application accessing shared Folder

Hello, I have an application running as service in windows server 2012. The Application requires a file path which if selected as shared folder(\\172.16.1.111\Data) can not locate or copy the file. however, if selected local path (C: or D:) it can locate and copy. Same application if running as console application instead of service can locate the same shared folder. What might be the issue?

From memory & it has been a while so may not be valid anymore. You can authenticate to the target by using a shell & executing "NET USE \\172.16.1.111\Data /user: ". Once this is done you can use folderitem to access that location.

it depends in which user context your app is running, if deamonized it may run under unpriviledged local service account. So check the context of your app first if it’s run on a server. Good practise is to use own username/password credentials for your service. In this case just login as this user on your server, connect to your shares and keep them persistent.

Without knowing what your app really does, it might be helpful not to use old, stinking SMB protocol to connect to shares. You problary gain more stablilized connections and better performance using your remote data as iSCSI volume mounted somewhere below a folder as mounting point.

This is from memory so you might need to improvise:

  1. Your service should be running under a proper Windows user - not administrator or Local System.

  2. On the server, login to the desktop with the user that the service is assigned to. If you are RDP’ing to the server you will need to enable RDP access for that user (remember to disable it afterwards).

  3. In the user account control panel you can configure the credentials for connecting to the share (eg: the path, user name and password).
    To test that you have entered them correctly you can put the UNC path into an Explorer window. If you are prompted to authenticate you have not configured the credentials correctly so you should cancel the dialog and edit the credentials. If the Explorer window shows the contents of the share then it is configured correctly.

  4. Logout of the user.

  5. Log back into the admin account and restart the service.

If you still cannot access the path then you might have to add additional privileges to the user account that the service is running under (for example, network access). Remember to restart the service every time you make a change.