How to run a script when the network connection changes

networkingscriptingwindows-xp

I'd like to create a script to do various things when the network connection changes. For example, if the machine connects to my office network I might desire it to:

  • mute itself
  • change its DNS
  • change its proxy settings
  • change default printer

Then, when the machine is off the office network it might revert some of those.

Presumably the "active network" would be based on IP address/gateway range or WIFI network name, etc.

Do you have any recommended tools for accomplishing this? I can see something like this being applicable to many IT pros so I'm sure there are some good tips out there.

Note that this is desired to function when the network changes–not just when the user logs on/off.

Best Answer

The "Network Location Awareness" service (http://msdn.microsoft.com/en-us/library/ms739931(VS.85).aspx) in Windows XP (and 2000? I don't recall...) and up will enable this functionality, but I haven't found where anybody has written an application to take advantage of it. I'd love to code something myself, but I don't have enough spare cycles to even begin to think about it.

This wouldn't be a simple little VBScript thing, but it wouldn't be that much coding either. Maybe somebody could pick up the idea and run with it. There's even sample code at http://www.microsoft.com/downloads/details.aspx?familyid=ef8a6228-f11d-4ba0-b73e-dd8dc7dd11e8&displaylang=en.

There have been numerous times I've wanted this functionality, and I'd think there are more than a few people who would like to see it.