0

Windows 10 Pro

Version 1709 OS

Build 16299.666

I have a service which would like to access network drive U:/public/blah.txt. Running it as a normal user with the command prompt works, running it as a service does not.

If go to services.msc -> servicename -> properties -> Log On -> This account and use MYDOMAIN/MYUSER and the correct password and restart, it still does not work, and produces the same error message. This is the account which can successfully run the program from the command prompt.

It's a golang executable running inside a nssm service and the actual error message is Error opening file U:\public\blah.txt: The system cannot find the path specified.

This program used to work as a service on a different computer, it's even accessing the same drive. the only difference I can see is that the account I'm using now is a domain account, whereas before it was a local user.

Why isn't my service seeing the drive mappings, if it is successfully logged in as the user who has them?

3
  • Is the service mapping the drive before it attempts to access it? Alternately, can you access the file using a UNC path instead of a mapped drive? Commented Oct 10, 2018 at 21:26
  • How is the drive being mapped? If the drive isn’t set to persist then it won’t be available in a service running as that user. In addition, if the domain account is a local admin you may have the UAC issue described here: fmsinc.com/microsoftaccess/developer/… in any case trying to access a mapped drive from a service is horrible, terrible, no good programming. Access the data directly via it’s UNC path. Commented Oct 10, 2018 at 21:30
  • The drive is already mapped by the user many reboots ago. The UNC path works on both, that was it. Post it as an answer and I'll accept. Commented Oct 10, 2018 at 21:40

1 Answer 1

0

Instead of having the service access the data via a mapped drive, use a UNC path name instead.

There are a variety of ways a drive can be mapped when a user profile is loaded. Not all of them are triggered when a service logs on using a particular account. For this reason, UNC paths are more reliable than mapped drives.

You must log in to answer this question.

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