Connecting to a network drive programmatically and caching credentials

Posted by Chris Doggett on Stack Overflow See other posts from Stack Overflow or by Chris Doggett
Published on 2010-05-10T14:55:48Z Indexed on 2010/05/10 15:14 UTC
Read the original article Hit count: 394

Filed under:
|
|

I'm finally set up to be able to work from home via VPN (using Shrew as a client), and I only have one annoyance. We use some batch files to upload config files to a network drive. Works fine from work, and from my team lead's laptop, but both of those machines are on the domain. My home system is not, and won't be, so when I run the batch file, I get a ton of "invalid drive" errors because I'm not a domain user.

The solution I've found so far is to make a batch file with the following:

explorer \\MACHINE1
explorer \\MACHINE2
explorer \\MACHINE3

Then manually login to each machine using my domain credentials as they pop up. Unfortunately, there are around 10 machines I may need to use, and it's a pain to keep entering the password if I missed one that a batch file requires.

I'm looking into using the answer to this question to make a little C# app that'll take the login info once and login programmatically. Will the authentication be shared automatically with Explorer, or is there anything special I need to do? If it does work, how long are the credentials cached?

Is there an app that does something like this automatically?

Unfortunately, domain authentication via the VPN isn't an option, according to our admin.

EDIT: If there's a way to pass login info to Explorer via the command line, that would be even easier using Ruby and highline.

© Stack Overflow or respective owner

Related posts about c#

Related posts about login