Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer
This method is better as it does not expose your password wherever your script lives. – user13846 Jul 28 '09 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 '09 at 16:16
it long as the account login id and password are the same on both ends (sans the domain part) – TheCleaner Aug 4 '09 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 '10 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 '10 at 18:27

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

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

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.

share|improve this answer

Less simple, but another option courtesy of SO.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.