Page 1 of 1 1
Topic Options
#188627 - 2008-07-09 12:22 PM Add reg keys based on ip address...
psykix Offline
Fresh Scripter

Registered: 2008-07-09
Posts: 12
I need to run different reg keys dependent upon the office a user is in.

They are all in the format 10.175.x.x, 10.131.x.x etc...

How can I do this?

The other thing - I'm learning, so just want to do this as a test.. How can I write a script that, if for instance the users IP address is 10.191.x.x it will display a message on the screen to say "You have logged on at the Manchester office" or if it is 10.131.x.x "You have logged on at the Liverpool office"

It's years since I used Kix32, and I've forgotten it all!

Thanks!

Top
#188630 - 2008-07-09 12:39 PM Re: Add reg keys based on ip address... [Re: psykix]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
 Originally Posted By: psykix

....
It's years since I used Kix32, and I've forgotten it all!
....


LOL It's like riding a bike. Start doing it and it all comes back.
This should get you going. Mind the space(s) when an IP octet is les then three characters long.

 Code:
Break on

Select
	Case Left(@IPADDRESS0, 8) = " 10.191."
		$rc = MessageBox ("You have logged on at the Manchester office", "Logon info...", 64)
	Case Left(@IPADDRESS0, 8) = " 10.131."
		$rc = MessageBox ("You have logged on at the Liverpool office", "Logon info...", 64)
	Case 1
		$rc = MessageBox ("Unable to determine your current office.", "Logon info...", 64)
EndSelect
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#188631 - 2008-07-09 12:54 PM Re: Add reg keys based on ip address... [Re: Mart]
psykix Offline
Fresh Scripter

Registered: 2008-07-09
Posts: 12
That's perfect!

Can you tell me how instead of displaying a message, I get it to run the following?

regedit32.exe example.reg

One other thing, Kix32 doesn't seem to run when I logon, despite having kix32.exe in the logon script in my account in AD... It runs fine if I run it from the command prompt though...

Thanks!

Top
#188632 - 2008-07-09 01:20 PM Re: Add reg keys based on ip address... [Re: psykix]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4402
Loc: New Jersey
You'd be much better served using an external table of subnets/office names/ data (tab delimited) and employ one of the IsInSubnet UDF variants. Hard coding data into a script makes it less portable and prone to errors when you need to modify/update it.

Look at the GetNetInfo UDF on my web site - it will do exactly what you need. Create a simple table of subnets, site names, and other data, delimited with tabs. When you feed the UDF an IP address, it will determine which subnet it is in and return a field from the corresponding record. There are defaults for field # and file location, but you can specify them in the UDF arguments.

Use the Shell command to kick off the regedit command.

If you are using Kix 4.60, you need to specify "Kix32.exe kixtart.kix" in your user profile. There's a bug in 4.60 that prevents it from locating the default startup script.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
#188663 - 2008-07-10 04:00 PM Re: Add reg keys based on ip address... [Re: Glenn Barnas]
psykix Offline
Fresh Scripter

Registered: 2008-07-09
Posts: 12
I've stuck with my hard coding - we only have 9 offices, so not too difficult to maintain..

Works perfectly so far!

Top
#188666 - 2008-07-10 05:19 PM Re: Add reg keys based on ip address... [Re: psykix]
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Instead of IP.. You could use INGROUP instead..

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#188680 - 2008-07-10 09:57 PM Re: Add reg keys based on ip address... [Re: Kdyer]
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Or the @site macro if all offices are configured as a different site in AD.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.136 seconds in which 0.097 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org