Jump to content

Detect Subnet


 Share

Recommended Posts

Hi there,

I'm having trouble working out a way to determine what subnet a script is running on, in which depending on the subnet it will perform different functions.

$LocalIP=@IPAddress1
if $LocalIP = "192.168.1." then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office1")
if $LocalIP = "192.168.2." then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office2")
if $LocalIP = "192.168.3." then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office3")
if $LocalIP = "192.168.4." then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office4")
$Site=IniRead("C:\Program Files\Info\xp.ini", "XP", "Site", "NOT FOUND")

The above does'nt work... I can make it work with > , but can prove unreliable. I'm not sure how to make it check a range of IPS...

Any guidance would be great...

thanks

Link to comment
Share on other sites

Any guidance would be great...

thanks

Check out stringinstr to find a specific string inside the returned IP address. Also, what do you get when you run ipconfig /all on one of these machines? If they have more than one network device they will return more than one ip address...
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Check out stringinstr to find a specific string inside the returned IP address. Also, what do you get when you run ipconfig /all on one of these machines? If they have more than one network device they will return more than one ip address...

Thank you for the pointer, working fine now!

$Subnet = StringLeft(@IPAddress1, 10)
if $Subnet = "192.168.1" then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office1")
if $Subnet = "192.168.2" then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office2")
if $Subnet = "192.168.3" then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office3")
if $Subnet = "192.168.4" then IniWrite("C:\Program Files\Info\xp.ini", "XP", "Site", "Office4")
$Site=IniRead("C:\Program Files\Info\xp.ini", "XP", "Site", "NOT FOUND")
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...