Create a batch file to connect to a network drive

5 pts.
Tags:
Batch files
Network drives
Shared drives
How do I transfer a file to a shared network drive through a batch file?
ASKED: December 14, 2008  9:06 PM
UPDATED: April 18, 2013  3:40 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Often it is asked how to create a batch file to map network drives for users at logon. Here’s how I did it at one site where I had a small number of users, but each user had a different set of mapped drives they needed to access.

Note, in this posting, “sbs1“ is the name of my SBS server. Substitute your SBS server name accordingly!

Location of script: The default SBS login script is located at c:\windows\sysvol\sysvol\sbs1\scripts and the script file is SBS_LOGIN_SCRIPT.bat.

Note: a quick way to get to this directory is to click Start > Run, and then enter \\sbs1\netlogon – and you will be right there, with no further drilling down any subdirectories!

1. First thing you want to do is to make a backup copy of the .bat file – just in case!

2. Next, edit the contents of the default .bat file so it looks like this, and then save it.

Rem Default SBS Login Script for users
\\sbs1\netlogon\%username%.BAT

3. I then created a new .bat file for each user. The name of the .bat file explicitly matched their actual logon name. So, if you logged on as JohnDoe, then the batch file was named JohnDoe.bat

Here is the content of one such user batch file:

Rem Batch File for user John Doe
NET USE Q: \\sbs1\Quickbooks
NET USE S: \\sbs1\SharedCompany
NET USE T: \\sbs1\Access

So, what happens is that when John Doe logs in, the default SBS script is started and immediately starts up the script file johndoe.bat, which has the various mapped drives to be declared.

4. Now, all you need to do is to create a new batch file for each user – no need to mess with the default SBS script any more. And no need to modify the name of the startup login script from within AD.

Add a new user? Simply add a new batch file!

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Karthikkumar
    I need to connect my server via bat files(EXE files).
    10 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following