Jump to content
Macro Express Forums

Read what building I'm plugged into?

Recommended Posts

I work for a school disctrict and move between two buildings. I'd like to make a macro that would "read" where I'm plugged in and then set the corresponding printer....


Our network system uses some type of "auto ip detection," where my computer just snags the first available ip address. Also, I'm an administrator of my laptop (Win XP), but I don't have tech authority that will let me alter the network settings of my workplace in any way. (And obviously I don't want to set off any hacker alarms!)


Any ideas how this could be accomplished?

Link to comment
Share on other sites

If the range of the IP address differs between locations you could use the Get IP Address command to get the IP address and check its range. An IP address consists of 4 numbers separated by a period. Each number can range from 0 to 255. One location may, for example, assign 192.168.0.xxx while another could assign 192.168.154.xxx. You could ask the network administrator or you could write a macro to display your IP address and keep track of the ones you are assigned. After a while you may detect a pattern.


Are there any unique resources such as servers available at one or the other location? You could have a macro attempt to map to a server and determine which network you are on that way.

Link to comment
Share on other sites

Awesome thanks!

It does appear this is going to work. The first two parts of the ip address are building-specific. I can save the ip as a text variable, then "variable modify: copy substring" of the first four characters back to the same variable. Then use the variable in a logic statement. I'll reply again in a couple of days and report if there were any quarks to doing this :P -steve

Link to comment
Share on other sites

  • 2 weeks later...

I just wanted to give an update: I've been using this method and it seems to work reliably.

Here's the code, incase anyone wants it (I changed the ip numbers to NN XX):


<GET IP ADDRESS Destination="%myip%"/>

<IF VARIABLE Variable="%myip%" Condition="\x06" Value="NN.N" IgnoreCase="FALSE"/>

<CHANGE DEFAULT PRINTER Printer="HP LaserJet P2015 Series PS" _PROMPT="0x0011"/>


<IF VARIABLE Variable="%myip%" Condition="\x06" Value="XX.X" IgnoreCase="FALSE"/>

<CHANGE DEFAULT PRINTER Printer="HP LaserJet P1500 Series PCL 5e" _PROMPT="0x0011"/>

<NUM LOCK Action="On"/>



It turned out to be the first several characters of the IP address that denote what building I'm plugged into. At first I was exrating the first four characters and doing an exact match, but that wasn't reliable because of a second IP that would showup in addition to the one for the building (The IP for "home" I think). Anyway, I just let the variable, myip, hold the entire string, and do the logic based on "Partial Match." Works great!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...