Roaming user login script needs to map drives...

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

axis77

Thread Starter
Joined
Aug 31, 2004
Messages
650
I have a user that moves from different locations every week, so for example he can be at area A with ServerA, then area B with ServerB
What im looking for is a way to run his login script that would know if he was at area A or Area B and mapped that specific servers folder share...
ex. current script
map network drive n: \\serverA\share

but if he was in Area B today his script still says
map network drive n: \\ServerA\share

How do I make a roaming script that knows if hes at AreaA or AreaB???
map network drive n: \\%Servername%\share

Any Ideas?
 
Joined
Aug 7, 2007
Messages
9,028
Assuming each location has been configured into a different Active Directory site, use gpresult (gpresult /R for Vista/Win 7) or a VBScript to get the Site name, then use that to read the appropriate server name from a list of sites
Code:
For /F "Tokens=3 Delims=: " %%I In ('gpresult ^|Findstr /I /C:"Site Name:"') Do Set _SiteName=%%I 
For /F "Tokens=2 Delims=:" %%I In ('Type Serverlist.txt^|Findstr /I "%_SiteName%"' ) Do Set _Servername=%%I
Serverlist.txt should be in the same folder as the logon script, or the path should be specified, andbe setup like this, using the correct site and server names:

Site1:ServerA
Site2:ServerB
Site3:ServerC

Example:
Building05:WarehouseServerA

This VBScript should be faster than waiting for the entire gpresult output to be generated.
Save the following as FindSite.vbs:
Code:
Set objADSysInfo = CreateObject("ADSystemInfo")
WScript.Echo "Site Name: " & objADSysInfo.SiteName
Then use this to get the site name
Code:
For /F "Tokens=3 Delims=: " %%I In ('cscript //nologo FindSite.vbs') Do Set _SiteName=%%I
For /F "Tokens=2 Delims=:" %%I In ('Type Serverlist.txt^|Findstr /I /C:"%_SiteName%"' ) Do Set _Servername=%%I
If you haven't set up sites, you'll need to find something you can read that is unique to each location, such as an IP address (Default Gateway, DNS, DHCP, WINS).
If the sites are not connected, you can use the logonserver variable, however, if a logon server isn't available, and the system logs on using cached credentials, the logonserver variable will contain the name of the last server that processed the credentials, which could be for a different site.
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Top