I have a wifi connection that requires to authenticate using a web form once the wireless link is established.I know how to automate the authentication with a script that uses
curl
/curlIE.But how can I ask Windows to call my script every time I connect to a particular network connection?
I would be also interested in receiving the name of the wireless profile or the ESSID on the command-line of my script.
Solution:
In Windows Vista and later, you can do this using a scheduled task with an event log trigger. The first event will be triggered by connecting to the network, and you will specify which network you must be connected to for it to run. The second event will be triggered when disconnecting from any network. Each event will run a specific task that you specify; likely the scripts you mentioned having written.
Setting an event for when you connect to the network:
- Open the Task Scheduler. You can find it by typing
Task Scheduler
into the start menu search box, or underPrograms | Accessories | System Tools
. In the Task Scheduler library, create a new task by clicking
Create Task
in the Actions panel on the right side.Give the task a name like “detect network connect” or whatever you choose
On the
Triggers
tab, clickNew...
and selectOn an Event
from the dropdown box.Choose the following settings:
- Log:
Microsoft-Windows-NetworkProfile/Operational
- Source:
NetworkProfile
- Event ID:
10000
- Log:
- Click OK, then go to the
Conditions
tab. - Check the box for
Start only if the following network connection is available
and choose the network you want to run the script with - Under the
Actions
tab, clickNew...
and selectStart a program
. Enter the location of the script file you want to run, then clickOK
. - Set any other task settings you want to, then click
OK
.
Setting an event for when you disconnect from the network:
- Follow steps 2-4 above
- Use the following event trigger settings:
- Log:
Microsoft-Windows-NetworkProfile/Operational
- Source:
NetworkProfile
- Event ID:
10001
- Log:
- Skip steps 6-7, as you will no longer be attached to any network at all. This event will therefore run any time you disconnect from any network.
- Follow steps 8-9 again