Link to home
Start Free TrialLog in
Avatar of ChrisJonesLycos
ChrisJonesLycos

asked on

Mapped drive letters in Windows Services

We've written a Windows Service which reads a path for data files from the Registry.

If the data file path is on a network rather than on the local machine we have found we need to run the Service using the Admin name and password in the Logon tab of the services manager.

However we have encountered another problem if the path is given as a mapped drive letter in the Registry. The Service cannot understand the drive letter (what were Microsoft thinking of??!!!) and therefore our Service is going to have to resolve this to a UNC pathname before using it.

We have no way of testing this before putting it on site so your advice appreciated. If we use the relevant API (or probably Delphi's ExpandUNCFilename) to get the full UNC pathname, will our Service be given the path or is this information hidden from all Services as some sort of security measure?

Many thanks.
Avatar of oBdA
oBdA

This is not an error from Microsoft. Mapped drives are *user* specific, *NOT* machine specific.
For the obvious reasons, if a service needs access to network resources, this service *has* to run under an account that has permissions to access this network resource. This can be a domain user account, or the local "Network Service" account (in which case the computer object needs permissions for the network resource).
Access to this network resource (and the service configuration) should happen with the UNC, not with a mapped drive.
Avatar of ChrisJonesLycos

ASKER

Many thanks, oBdA.

When you say "the local "Network Service" account (in which case the computer object needs permissions for the network resource)" I don't really understand. Would you mind explaining this to me.

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Many thanks. That's very helpful.