Mapping of network drives via batchfile

If you work in a ActiveDirectory based environment and all your clients are connected to the domain, you might not have to deal with manually map home drives and other resources.

However, if some of your clients are not connected to the domain, but need access to domain resources, you probably noticed that it can be pretty annoying having service calls because of forgotten network paths and locked accounts.

To encounter that problem, I wrote a quick and dirty script, which gives the user a basic dialogue driven netdrive-mapper, so your service desk gets rid of the most basic calls.


@ECHO OFF

ECHO Removing all available mappings...
PAUSE
NET USE * /D

:USER
ECHO Attempting to connect to SERVER and map your homedrive...
PAUSE
SET /P USER=Please enter your username (username@domain.local):
NET USE U: \\server.domain.local\%USER:~0,-13%$ /USER:%USER% /PERSISTENT:NO

ECHO Attempting to connect to SERVER and map your Groupdrives...
PAUSE

:GROUP1
SET /P GROUP1=Please enter your main Group:
NET USE V: \\server.domain.local\%GROUP1% /PERSISTENT:NO
SET /P CONTINUE=Add another Groupdrive? (y or n)

IF /I '%CONTINUE%'=='y' GOTO GROUP2
IF /I '%CONTINUE%'=='n' GOTO PUB
ECHO "%CONTINUE%" is not valid. Going to map public drives GOTO PUB

:GROUP2
SET /P GROUP2=Please enter your second Group:
NET USE W: \\server.domain.local\%GROUP2% /PERSISTENT:NO
GOTO PUB

:PUB
ECHO Attempting to connect to SERVER and map public drives...
NET USE p: \\server.domain.local\public /USER:%USER% /PERSISTENT:NO
GOTO PRINTERS

:PRINTERS
ECHO Attempting to connect to SERVER and map printers...
PAUSE
START \\server.domain.local\printer1
START \\server.domain.local\printer2

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.