Link to home
Start Free TrialLog in
Avatar of T.J.
T.J.

asked on

Simple Script to Map Drives

I'm setting up a laptop to connect to a server I have here that's on a domain. This machine is not part of the domain. Every time this person comes here they need to reconnect to the drive, enter username and password to connect to the share.

Here is what I am looking to do, I have very little coding experience, but I want to place an icon on the desktop or somewhere on the laptop that when clicked will automatically map to the needed share, enter the username/password, and be simple to integrate.

Nothing to complex, probabaly something with a net use command.

Thanks for the help!
Avatar of KaliKoder
KaliKoder
Flag of Canada image

Hello ITGL72-

You can use the following script. Copy paste in notepad, and save file as MapDrive.Bat on the Desktop.

REM ************************************************
@echo off
echo This Drive maps your Network Drive and uses Drive letter M:
net use M: /d yes
net use M: \\serrvernamehere\sharenamehere
echo Drive mapping complete
REM ************************************************

Thanks and Good Luck!
ASKER CERTIFIED SOLUTION
Avatar of KaliKoder
KaliKoder
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of T.J.
T.J.

ASKER

Worked like a charm - thanks!

Out of curiosity...

You know when you map a net drive in windows and there is a checkbox that asks if you want to reconnect at logon? Is there a way to integrate that into this script so that the next time the laptop is turned on, and there is no connection to THIS network it does not pop up and ask that question it asks when it cannot find a previous mapped drive?

Thank You!

Yes thats called a persistent connection, and you can integrate that into the script, just do the following:

REM ************************************************
@echo off
echo This Drive maps your Network Drive and uses Drive letter M:
net use M: /d yes
net use M: \\serrvernamehere\sharenamehere /persistent:Yes /user:theusernamehere theuserpasswordhere
echo Drive mapping complete
REM ************************************************
Avatar of T.J.

ASKER

Hey folks, wonder if I could touch base on this topic again.
Heres my script:

REM ************************************************
@echo off
echo This Drive maps your Network Drive and uses Drive letter F:
net use F: /d yes
net use F: \\server\sys$\Apps\Accounting\PeachTree-Accounting-STI /user:domain.com\firstname.lastname password
echo Drive mapping complete
REM ************************************************


I get the error: "A command was used with conflicting switches."

Any suggestions? Do you think I should just re-open this issue as a NEW QUESTION here?