I want to make my system auto lock whenever I disconnect the Ethernet cable or my LAN signals drops. I'm using Windows 7 and Windows 10.
According to this answer: http://asianhospital.com/?id=a/225251/950764 an event will be created when your connections drops. The ID will be 27 and the source depends on your network card. (the answer mentions "e1yexpress" but for me it is "e1dexpress")
This allows you to create and event in Task Scheduler that will execute when your connections drops.
- Open Event Viewer and filter for Events with the ID 27 and level "Warning" under
Windows Logs -> System.
- Now you should see events mentioning your network cards name and the text "Network link is disconnected" (assuming this has been the case till now). Most importantly you will now know the events source, which you need to use for the scheduled task.
- Open Task Scheduler and create a new task.
- In the properties window that opens give the task an name.
- In the Trigger tab create a new trigger and select "On a new event". Set Log to "System", source to the name you got from Event Viewer and Event ID to 27. Press OK.
- Now go to the Actions tab a and create a new action. In the windows that opens select
"Start a program" and enter
rundll32.exeas program path and
user32.dll,LockWorkStationas arguments .
- You may want to customize the task a bit further like disabling the fact that the
task will only run if the power is plugged in under the Conditions tab (mostly
relevant for laptops)
After doing this I recommend disconnecting your network cable to check if everything works as expected.