What must I do to cause a script or batch file to be run when the computer succeeds connecting to a network with a specific SSID, in Windows 7 Ultimate?

I need it to be triggered by connecting to a wireless network, so doing timed checks won't be a solution in my case (timed checks for specific IPs have been proposed in a similar question). I have also tried Net Profiles but it refuses to run (I haven't found a solution for this), so I want to do this without Net Profiles.

This will be used in a small company's office. For example, among the other tasks that connecting to our network will trigger, one of them is running a batch file that replaces certain files (one of them is hosts, to associate our file server's alias with its LAN ip when the laptops connects to our WLAN, and to associate the same alias with that server's 'no-ip' address as soon as it disconnects from our WLAN). Since the above example is not the only task that this mechanism needs to do, an alternate solution that only solves the problem of selecting the correct hosts file won't work, unfortunately.

link|improve this question
1  
I know you have other things you want to do, but why would you mess around with the hosts file? Why wouldn't you have a working DNS server on your network that simply responds with the correct information, that is served up via DHCP? – Zoredache Nov 8 '11 at 20:37
The DNS resolving is done by a simple WRT-54g wireless router + the DSL modem. That router does not support DHCP preallocation by MAC address, and additionally, we want the Internet access route to be "Computer -> router-> modem -> Internet", and without relying in any way on any of the other computers. – Gustav B. Nov 8 '11 at 23:28
Flash the router with with one of the many custom firmware solutions available, you will get DNSMasq, which has a huge amount of flexibility as a DNS/DHCP server. – Zoredache Nov 8 '11 at 23:32
I will try it out, thank you very much. However it only solves one of the problems, which is the hosts alteration. I need other tasks to be done as well triggered by change of wireless connection, and some of them need to occur on networks over which we have no control. – Gustav B. Nov 8 '11 at 23:36
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.