I had this exact question, and Darren's answer was on the right track, but didn't get me all the way there. Here's what I ended up doing.
First determine which event you want to use to trigger the task. Run the Event Viewer program and navigate to:
Applications and Services Logs > Microsoft > Windows > WLAN-AutoConfig > Operational
In my case, I didn't want my task to run until I was actually connected to a specific WiFi network, so the Event ID I needed was
8001. The quick way to create a task based on this event is to right-click on the event and select "Attach Task To This Event..."
In the window that pops up, name your task something clever and add a description so you'll remember what it is later. Go through the wizard, selecting the program you want to run, etc., and when it gets to the last screen, check the box that says "Open the Properties dialog for this task when I click Finish".
At this point, the task will run when the computer successfully connects to any wireless network. To limit it to one particular network, you'll have to modify the task to filter for something unique in the meta data, like the network's SSID. In the properties dialog for the new task, go to the Triggers tab and edit the trigger.
Now, make note of the values for the Basic trigger. You're going to switch to a Custom trigger, and when you do, it'll start blank and you'll need to fill the values in again. After clicking "New Event Filter..." recreate the basic filter by selecting the necessary Event log, Event source, and entering the Event ID.
Note that there's no place to specify meta data from a particular event (such as the SSID of the wireless network). You'll need to edit the raw XML to make this happen, as I discovered in this article.
To figure out which meta data you need to filter in the Event Log, go back to the Event Viewer and click the Details tab for the event. Switch to the XML view. For this particular case, the relevant bit looks something like this:
<Data Name="SSID">Your WiFi Network</Data>
Back on the New Event Filter dialog, switch to the XML tab and check the box next to "Edit query manually".
Referring back to the article linked above, you'll see that the string you need to add will look something like this:
and *[EventData[Data[@Name='SSID']='Your WiFi Network']]
Paste this right before the
Boom. You're done.
Just a note that might make this easier, rather than editing the XML for the trigger, you can switch to the Conditions tab when bringing up the properties for the task. Here there is an option to 'Start only if the following network connection is available:' and provides a drop down list of networks that you have previously connected to. I suspect this would filter the trigger appropriately as well. Justin