3

I have a service that I need to be able to write to a network share on another machine using a local account on that machine. To do this I either need to map a network drive that can be seen by the service (logging in as the user the service runs under and mounting the drive does not seem to work), or I need to be able to specify the unc path with a username and password as part of the configuration of my service.

Are either of these things possible?

4 Answers 4

6

the above answer should work....but an easier approach would be to create a local account on both boxes with the same username and password. Then set your service to run under that local account name on ServerA and set ServerB's network share permissions to allow for that local account name on ServerB. Since they are the same username and password it should allow access to the share.

Or better still...make a domain account and use that for both ends.

5
  • This method is better as it does not expose your password wherever your script lives.
    – user13846
    Jul 28, 2009 at 15:57
  • will this work for a domain account on one end and a local account on the other end? I ask because I have a few machines on the same domain that would benefit from the domain account. but one that is outside the domain and so would need a local account.
    – Jack Ryan
    Jul 28, 2009 at 16:16
  • it should...as long as the account login id and password are the same on both ends (sans the domain part)
    – TheCleaner
    Aug 4, 2009 at 20:35
  • When you say "the above answer should work" which answer are you referring to? This is (currently) the top rated answer, so there is no answer "above" it.
    – rjmunro
    Jun 10, 2010 at 9:03
  • Rjmunro - I was referring to the one by routeNpingme. Notice his comment is timestamped before mine. That was the one I was referring to.
    – TheCleaner
    Jul 20, 2010 at 18:27
5

You can specify username/password with the net use command.

net use Z: \\Server\SharedFolder passwordGoesHere /USER:userAccountGoesHere /persistent:no
1
  • How do I go about doing this for my service through. It still doesnt add the share for the service.
    – Jack Ryan
    Jul 28, 2009 at 16:14
1

What account is the service running under? Is it localsystem or some other account? While the best approach is to use domain user/same user&pass local user for achieving what you want, another alternative is to use the Credential Manager in Windows. You can add a credential for the remote machine while running in the same context the service will run and the authentication subsystem will pick it up automatically. You can easily do this with cmdkey.exe in command prompt for the service account.

0

Less simple, but another option courtesy of SO.

You must log in to answer this question.

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