Map Network Drive using different credentials

crafty42

New Member
Joined
Oct 18, 2015
Messages
6
I need to map a network drive that I'm given access to with a username/password to get into the subfolders and copy files over to my local PC. I've been working on code using several options, but to no avail. The one method I did get to work was using cmd.exe and "net use...." which maps the drive, but doesn't seem to pass the credentials on to the subfolders which I can't get in to.

The long way to map it, if it helps, is to right click "this pc", select map network drive, put in the "\\IPAddress\foldername", check the box to "Connect using different credentials" Click finish. On the next popup I need to click "More Choices" and select "Use a different account" (otherwise it tries to use my current network credentials). Then I put in the domain/username and my temporary password.

I'm trying to develop a vba macro that can do this all for me just by putting in the username and password on a form. Any assistance would be appreciated.
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Oh crap. I can't seem to edit my post, maybe I'm still too new. I just manually mapped the drive and it still won't let me in the subfolders, so maybe it isn't my code that's the problem.

I'd still take opinions on the best way to code the mapping other than "net use"
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top