Jump to content
Sign in to follow this  
attactician

Get IP address then execute script

Recommended Posts

attactician

Hello, I have an idea for a script, but I don't know how to proceed. Here is the basic logic that I would like to replicate in a simple autoit script:

Get IP address of local machine (from any of my two network adapters, Ethernet or wireless adapter)

IF IP = 10.*.*.* (in other words, if the ip matches the first octet of my work's DHCP range)

Then Execute script1

Else = Execute script2

EndIf

Exit

Simple huh? Not for a newb like me! Any suggestions would be greatly appreciated!

Share this post


Link to post
Share on other sites
Pain

Make two functions.

If StringLeft(_GetIP, 3) == "10." Then

Function1()

Else

Function2()

EndIf

Share this post


Link to post
Share on other sites
james3mg

Hello, I have an idea for a script, but I don't know how to proceed. Here is the basic logic that I would like to replicate in a simple autoit script:

Get IP address of local machine (from any of my two network adapters, Ethernet or wireless adapter)

IF IP = 10.*.*.* (in other words, if the ip matches the first octet of my work's DHCP range)

Then Execute script1

Else = Execute script2

EndIf

Exit

Simple huh? Not for a newb like me! Any suggestions would be greatly appreciated!

Please don't double-post.

Look in the helpfile at @ipaddress1, @ipaddress2, etc. You'll also probably want to look at StringLeft(). Past that, we're going to need to know more details. Are they really two scripts (that is, different files) that you want to conditionally execute? If it's possible, I'd recommend just using your If...Then statement to do different things.

If [your condition here] Then
  MsgBox(0,"Hi","I'm at work!")
Else
  MsgBox(0,"Hi","I'm not at work!")
EndIf

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites
Andreik

$SPLIT = StringSplit(@IPAddress1,".")
If IsArray($SPLIT) Then
    If $SPLIT[1] = "10" Then
        MsgBox(0,"","Script 1")
    Else
        MsgBox(0,"","Script 2")
    EndIf
EndIf


When the words fail... music speaks

Share this post


Link to post
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
Sign in to follow this  

×