If you happen to be using a Thinkpad, you can take advantage of ThinkVantage Access Connection, available for Windows 7, Vista and XP.
ThinkVantage Access Connection is the network connection manager software shipped with ThinkPad - if not, downloadable from their support site. When you make a new profile for your location, there is a wizard which asks if you want to configure a list of program to start when that location is connected. It offers to kill the program when the net is out, too.
Note that the software can be configured to work without any location profile at all, and that's perhaps the initial status - in that case, there is no way to configure a list of program to start when wifi is connnected: you have to create a connection profile to contain the list.
For my own experience, I try to avoid using the software - it takes a lot more time to get connected than without it, and sometimes fails to establish new connection when booting (can be fixed by manually reconnect).
The software only works with the WIFI driver provided with the thinkpad.
On a side note, this software offers to establish connection before user logs in, as an option when you create the profile. I don't know if this is possible without it.
Did you ever get an answer to this that satisfied your question? – Menasheh – 2016-11-10T23:30:36.067
1
Probably useless but I found this through googling. It apparently enumerates your connections and might provide something you can query with a script to determine when an adapter connects/disconnects. http://msdn.microsoft.com/en-us/library/ms739931%28v=VS.85%29.aspx
– CreeDorofl – 2011-03-26T19:26:16.383I don't want to have to check the state every few seconds. Network Location Awareness notifications is interesting, but I see no easy way to use it with only scripting.
– dolmen – 2011-03-26T20:23:59.347dolmen - is there a way you can post the script you wrote for the authentication too. this question would be a lot more complete with it in it. – quest49 – 2012-05-04T20:19:13.383
@quest49 I understand that my script may interest you, but it is irrelevant to the question. – dolmen – 2012-10-24T19:54:44.847