Map Shared Drives and Printers using Batch Scripts and Net Use Command

When I log into a new computer, I don’t like having to do a whole lot of configuration.  Net use command is the command line tool for mapping shared drives and printers.  You can combined it with a batch script to map shared storage drives and printers.  Now you have a really efficient tool at your disposal.  Here is a sample of one of my scripts.  If you would like to try and make your own batch script to automatically map a shared drive or printer with a click of an icon on your desktop.  Open up your notepad app and copy / paste the following script.  Once you are done editing the script in notepad app – Save it as a “.bat” file.

  • Swap out the placeholder with your share’s IP address (In example: \\192.168.X.X or \\domain.local).
  • If your share has spaces in its name use “\\yourserver.local\share name
  • Add as many shares and printers as you want by adding more Net Use lines in the script.

shared_mapping

 

Shared Drive Mapping Sample


echo off
title S Drive Automatic Mapping.

echo Creating new S: Drive Mapping...
net use S: \\yourserver.local\share

:exit
pause

 

Shared Printer Mapping using Net Use command


echo off
echo Mapping YourLocation Printer and Copier...
rundll32 printui.dll PrintUIEntry /in /n \\yourserver.local\PrinterName\
echo Mapping Maintenance Control Printer and Copier...
Net Use LPT1 \\yourserver.local\PrinterName\ /Persistent:Yes
:exit
pause

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s