27

In my day to day work, I need to access data on shared folders using different credentials (my desktop account is not the same as the account I use to access these servers). Normally, I'd map a few drives and be done with it; the problem is I access 40-50 different servers on a daily basis - and it is not the same servers each day.

What I've been doing thus far is basic, and annoying - but it somewhat works. I have a folder with subfolders organizing the shortcuts to each shared folder. Each shortcut is simply a \\servername\folder pointer - which I double click and am prompted to enter my credentials.

What I'd like to do is use some sort of application (or a batch file) to just launch an explorer window already pointed to the share, with the credentials already entered. While it's easy enough to create a command line shortcut to net use which maps the drive, due to the number of drives I interact with mapping a drive is out of the question.

TL;DR: Is there a way to do something like:

explorer.exe /user:domain\username /pass:Pa55w0rd! /folder:\\servername\folder

and have it pop up an explorer window to that path?

7
  • I'm confused. Are you looking for the net use command?
    – MDMarra
    Mar 6, 2014 at 23:12
  • Net use is the correct command, or you can use the new-psdrive command in Powershell (requires 3.0, enter $psversiontable at the prompt to determine what version you are running).
    – Davidw
    Mar 6, 2014 at 23:54
  • Welcome to Server Fault! Questions must be relevant to professional system administration. Server Fault is a site dedicated to professionals; novice questions are off-topic as are questions related to home or personal use scenarios. Please see the Help Center for more information on topicality.
    – TheCleaner
    Mar 7, 2014 at 0:52
  • I'm familiar with net use, if you read my comment you'll note that I specifically cannot use the net use command. I'm trying to simply open an explorer window to the specified path with credentials, there are too many (and they change too often) to mount as a network drive.
    – rage8885
    Mar 7, 2014 at 14:30
  • 1
    @kagaku I think you're not 100% clear on all of the options with net use. You don't need to map a drive with it. You can simply specify alternate credentials with the UNC path
    – MDMarra
    Mar 7, 2014 at 14:35

1 Answer 1

48

It seems like you've missed an important part of net use before you ruled it out as a solution. You don't need to specify a drive letter with it.

net use \\server\share /user:test testpassword will work just fine. You don't need to specify a drive letter. This will allow access to that UNC path under the specified credentials.

Once you have the UNC path available under alternate credentials, you can launch an explorer session to the UNC path manually or by using start.exe as in start \\server\share.

A little two-liner as an example would be

net use \\server\share /user:test testpassword
start \\server\share
5
  • You're right, I wasn't aware that drive letter was optional. Thank you for explaining, this is exactly what I was looking for.
    – rage8885
    Mar 7, 2014 at 15:41
  • 1
    Not sure if its just a windows 7 thing, but you don't use the /password to set the password, its expected after the sharename, so in the above example just omit the /password: bit. i.e. net use \\server\share /user:test test May 2, 2016 at 9:03
  • 1
    @SteveChilds is correct, there should be no "/password:" prefacing the password.
    – Tony
    Oct 6, 2016 at 2:07
  • Sweet! I was looking for this exact thing today to add to a script for installing files from network shares - no more USB for meeeee! :-) Feb 20, 2017 at 21:31
  • Don't you need to delete the connection somehow afterwards? How would you do that? NET USE ???? /DEL ??
    – IqbalHamid
    Apr 9, 2021 at 3:36

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