Logon Script that switches servers.

Hewlett-packard Ms windows server 2003 r...
June 26, 2013 at 09:38:43
Specs: Windows 2008, Quad Core / 2Gig
I have an employee that will be switching between office. I need a logon script that will map drives depending on which subnet he is logging on. Here is one of my logon scripts.

@echo off
echo y|net use i: /delete
echo y|net use h: /delete
echo y|net use j: /delete
echo y|net use k: /delete
echo y|net use m: /delete
echo y|net use n: /delete
echo y|net use o: /delete
echo y|net use p: /delete
echo y|net use z: /delete

:SVR020
net use h: "\\svr020\users\%username%"
net use i: "\\svr020\share"
net use j: "\\svr020\department\general"
net use k: "\\svr020\department\OAM"
net use m: "\\svr020\department\OMH"
net use n: "\\svr020\department\OFM"
net use o: "\\svr020\department\OCP"
net use p: "\\svr020\archives"
net use z: "\\svr020\users"
:END

I have different GPOs for each office which run different logon scripts but this employee will belong to both offices so I was going to setup a different GPO for employees that switch offices or have a generic script that works for the domain.

I need a script that will map to "\\SVR020" when logging in on the 10.100.100.x /24 subnet and "\\SVR110" when logging in on the 10.100.101.x /24 subnet. Is there a way to look at the 3rd octet to determine which server to use? Like:

@echo off
echo y|net use i: /delete
echo y|net use h: /delete
echo y|net use j: /delete
echo y|net use k: /delete
echo y|net use m: /delete
echo y|net use n: /delete
echo y|net use o: /delete
echo y|net use p: /delete
echo y|net use z: /delete

if "3rd octet" == 100 goto :SVR020
else goto :SVR110

:SVR020
net use h: "\\svr020\users\%username%"
net use i: "\\svr020\share"
net use j: "\\svr020\department\general"
net use k: "\\svr020\department\OAM"
net use m: "\\svr020\department\OMH"
net use n: "\\svr020\department\OFM"
net use o: "\\svr020\department\OCP"
net use p: "\\svr020\archives"
net use z: "\\svr020\users"
goto :END

:SVR110
net use h: "\\svr110\users\%username%"
net use i: "\\svr110\share"
net use j: "\\svr110\department\general"
net use k: "\\svr110\department\OAM"
net use m: "\\svr110\department\OMH"
net use n: "\\svr110\department\OFM"
net use o: "\\svr110\department\OCP"
net use p: "\\svr110\archives"
net use z: "\\svr110\users"

:END

I am also not apposed to Power Shell or VBS as another way of doing it. Thanks.


See More: Logon Script that switches servers.

Report •

#1
June 26, 2013 at 11:35:32
Question: Are both servers accessible from either location?

EDIT:
Side note: "net use i: /d /y" is easier to type than "echo y|net use i: /delete"

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question