?
Solved

Smart Logon Scripts

Posted on 2006-05-09
11
Medium Priority
?
468 Views
Last Modified: 2008-02-26
Hi all,

I have two different offices in two locations. They are linked using a leased line and there is a domain controller on each end which syncs accross the leased line. There is a different logon script for the users in each office. There are however a number of users that work from both offices. How can i get the logon script to know which office the user is loggin on to and run the correct script for that office. I am using a bat file to map drives, set up printers and start programs.

Thanks

Pauraic
0
Comment
Question by:CSEAITDept
  • 5
  • 3
  • 3
11 Comments
 
LVL 57

Accepted Solution

by:
Pete Long earned 1200 total points
ID: 16640819
Get an IP address at site 1 for axample if the router there is 194.189.188.1

then set the loigin script as

:: -----EXAMPLE.BAT------
@ECHO OFF
PING 194.189.188.1 | FIND "TTL" > NUL
IF NOT ERRORLEVEL 1 (

<commands to execute at site 1>

) ELSE (

<commands to execurte at site 2>

)
:: -----EXAMPLE.BAT------

If you need this to work on DOS/Win9x as well, we have to modify it slightly... DOS/Win9x doesn't like continued IF statements. This one will work on DOS/Win9x/WinNT/2K/XP:

:: -----EXAMPLE.BAT------
@ECHO OFF
PING 194.189.188.1 | FIND "TTL" > NUL
IF NOT ERRORLEVEL 1 GOTO PINGGOOD
GOTO PINGBAD

:PINGGOOD

<commands to do at site 1>

GOTO END

:PINGBAD

<commands to do at site 2>

:END
:: -----EXAMPLE.BAT------

Hope this helps,
0
 
LVL 4

Expert Comment

by:Nat_c
ID: 16640893
Hi,
 
There is a variable called "logonserver" you could include an if statement along the lines of:

"if %%logonserver%%==server1 goto 1
if %%logonserver%%==server2 goto 2
:1 server 1 logon stuff
:2 server 2 logon stuff"
(not entirely sure of the syntax but can find out for sure if you need me to.)

It may not be fool proof though as it is technically possible for someone at location 1 gets logged on by server2

Another alternative would be a prompt asking the user which office they are at, this would obviously require user input so isn't a completely automated process.

Hope this helps,
Nat
0
 

Author Comment

by:CSEAITDept
ID: 16640908
Hi,
Thanks for the speedy reply. The routers and computers on both sites can be pinged from both sites. this is required for our phone & doc management system. Is there any thing else that can be used to check. The DHCP server on one side gives ipaddreses of 192.168.0.* and the other 192.168.1.*. Can the script check its own ipaddress.

Pauraic
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Assisted Solution

by:Nat_c
Nat_c earned 800 total points
ID: 16640934
you could adapt PeteLong script slightly (his is better than my suggestion) to run ipconfig instead of ping and search for 192.168.0

Nat
0
 

Author Comment

by:CSEAITDept
ID: 16641025
Hi,

Can you check which if a user is a member of a group from a bat file?

Pauraic
0
 
LVL 4

Expert Comment

by:Nat_c
ID: 16641118
I assume you mean as in a domain security group.

This is not possible without using a third party application to the best of my knowledge.

There is a piece of software called kix, you will find plenty of resources/login script examples on here and the web, that allows you to create more complicated scripts including the ability to check group and possibly OU membership.

Kix group membership example
http://www.experts-exchange.com/Operating_Systems/Win2000/Q_20623631.html

Nat
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 16641186
>>Can you check which if a user is a member of a group from a bat file?

Nat_c is correct - though you CAN use IFMEMBER.exe its in one of the resource kits hang on...................
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 16641191
................. I never throw anything away :)

Using ifmember.exe

http://www.microsoft.com/windows2000/techinfo/reskit/tools/new/ifmember-o.asp

in your script first you have to give the clients the ifmember.exe command so put this in your script

-------------cut below--------------
if not exist %windir%\system32\ifmember.exe copy \\%logonserver%\netlogon\ifmember.exe %windir%\system32
-------------cut above--------------

this assumes you put ifmember in the servers netlogon folder

then put this in the script
-------------cut below--------------
ifmember /list >%temp%\ifmember.txt
-------------cut above--------------

This caches all the groups locally on the client in a text file

Then put the commands in for each group eg.

-------------cut below--------------

find /i %temp%\ifmember.txt "group1" >NUL IF %ERRORLEVEL% == 0 start /min NET USE P: \\server_name\group1

find /i %temp%\ifmember.txt "group2" >NUL IF %ERRORLEVEL% == 0 start /min NET USE P: \\server_name\group2

-------------cut above--------------

This would map a P: drive for every member of the "group1" group to the \\server_name\group1 folder and group2 to the group 2 folder etc
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 16641220
>> (his is better than my suggestion)

oh contrare - I prefer your solution =D
0
 

Author Comment

by:CSEAITDept
ID: 16641616
Thanks lads, The ipconfig in the script did the trick, will investigate the group thing further though, food for though and that. thanks
0
 
LVL 57

Expert Comment

by:Pete Long
ID: 16642259
ThanQ
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Disclosure: Use this tutorial only when no other options helps to get Windows XP running without any problems and you don't want to format the drive. The back up of the data is the responsible of the user, however there is a description of how t…
We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month14 days, 15 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question