Auto-lock (Win+L) computer if Ethernet cable is removed or Ethernet signals drops











up vote
0
down vote

favorite












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.










share|improve this question
























  • Welcome to Super User! Please note we are not a code-writing service, and questions seeking product recommendations are off-topic. Instead, post specific issues you are having with a script (for example), and folks may be able to help with that. Cheers!
    – bertieb
    Dec 1 at 13:44






  • 1




    Also, just supposing hypothetically it happened to be in a corporate environment you wanted to enforce something like that, you may be better off pursuing non-technical avenues of approach.
    – bertieb
    Dec 1 at 13:49















up vote
0
down vote

favorite












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.










share|improve this question
























  • Welcome to Super User! Please note we are not a code-writing service, and questions seeking product recommendations are off-topic. Instead, post specific issues you are having with a script (for example), and folks may be able to help with that. Cheers!
    – bertieb
    Dec 1 at 13:44






  • 1




    Also, just supposing hypothetically it happened to be in a corporate environment you wanted to enforce something like that, you may be better off pursuing non-technical avenues of approach.
    – bertieb
    Dec 1 at 13:49













up vote
0
down vote

favorite









up vote
0
down vote

favorite











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.










share|improve this question















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.







windows shell-script lock






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 3 at 0:53









Twisty Impersonator

17.3k126394




17.3k126394










asked Dec 1 at 13:31









CYREX

32




32












  • Welcome to Super User! Please note we are not a code-writing service, and questions seeking product recommendations are off-topic. Instead, post specific issues you are having with a script (for example), and folks may be able to help with that. Cheers!
    – bertieb
    Dec 1 at 13:44






  • 1




    Also, just supposing hypothetically it happened to be in a corporate environment you wanted to enforce something like that, you may be better off pursuing non-technical avenues of approach.
    – bertieb
    Dec 1 at 13:49


















  • Welcome to Super User! Please note we are not a code-writing service, and questions seeking product recommendations are off-topic. Instead, post specific issues you are having with a script (for example), and folks may be able to help with that. Cheers!
    – bertieb
    Dec 1 at 13:44






  • 1




    Also, just supposing hypothetically it happened to be in a corporate environment you wanted to enforce something like that, you may be better off pursuing non-technical avenues of approach.
    – bertieb
    Dec 1 at 13:49
















Welcome to Super User! Please note we are not a code-writing service, and questions seeking product recommendations are off-topic. Instead, post specific issues you are having with a script (for example), and folks may be able to help with that. Cheers!
– bertieb
Dec 1 at 13:44




Welcome to Super User! Please note we are not a code-writing service, and questions seeking product recommendations are off-topic. Instead, post specific issues you are having with a script (for example), and folks may be able to help with that. Cheers!
– bertieb
Dec 1 at 13:44




1




1




Also, just supposing hypothetically it happened to be in a corporate environment you wanted to enforce something like that, you may be better off pursuing non-technical avenues of approach.
– bertieb
Dec 1 at 13:49




Also, just supposing hypothetically it happened to be in a corporate environment you wanted to enforce something like that, you may be better off pursuing non-technical avenues of approach.
– bertieb
Dec 1 at 13:49










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










According to this answer: https://superuser.com/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.




  1. Open Event Viewer and filter for Events with the ID 27 and level "Warning" under
    Windows Logs -> System.


  2. 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.

  3. Open Task Scheduler and create a new task.

  4. In the properties window that opens give the task an name.

  5. 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.

  6. Now go to the Actions tab a and create a new action. In the windows that opens select
    "Start a program" and enter rundll32.exe as program
    path and user32.dll,LockWorkStation as arguments .

  7. 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.






share|improve this answer





















  • I will try it. Thanks for very informative/applicable answer.
    – CYREX
    Dec 1 at 14:18










  • It worked at my home computer. I want to implement it at my office. I m using windows server 2008 as a server and i want to deploy this task to all my domain users. As every system has its own network card and source will be different for each computer. Is there anyway i can put universal source name for network disconnection or i have to go to each computer to create that task?
    – CYREX
    Dec 1 at 14:58










  • In that case you could switch the trigger from Basic to Custom. If you press new Event Filter and switch to "By source" you can select multiple sources. If you only have very few computer models you could check there event logs and see how the source is called and add them all.
    – User025
    Dec 1 at 15:07











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379966%2fauto-lock-winl-computer-if-ethernet-cable-is-removed-or-ethernet-signals-drop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










According to this answer: https://superuser.com/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.




  1. Open Event Viewer and filter for Events with the ID 27 and level "Warning" under
    Windows Logs -> System.


  2. 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.

  3. Open Task Scheduler and create a new task.

  4. In the properties window that opens give the task an name.

  5. 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.

  6. Now go to the Actions tab a and create a new action. In the windows that opens select
    "Start a program" and enter rundll32.exe as program
    path and user32.dll,LockWorkStation as arguments .

  7. 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.






share|improve this answer





















  • I will try it. Thanks for very informative/applicable answer.
    – CYREX
    Dec 1 at 14:18










  • It worked at my home computer. I want to implement it at my office. I m using windows server 2008 as a server and i want to deploy this task to all my domain users. As every system has its own network card and source will be different for each computer. Is there anyway i can put universal source name for network disconnection or i have to go to each computer to create that task?
    – CYREX
    Dec 1 at 14:58










  • In that case you could switch the trigger from Basic to Custom. If you press new Event Filter and switch to "By source" you can select multiple sources. If you only have very few computer models you could check there event logs and see how the source is called and add them all.
    – User025
    Dec 1 at 15:07















up vote
1
down vote



accepted










According to this answer: https://superuser.com/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.




  1. Open Event Viewer and filter for Events with the ID 27 and level "Warning" under
    Windows Logs -> System.


  2. 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.

  3. Open Task Scheduler and create a new task.

  4. In the properties window that opens give the task an name.

  5. 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.

  6. Now go to the Actions tab a and create a new action. In the windows that opens select
    "Start a program" and enter rundll32.exe as program
    path and user32.dll,LockWorkStation as arguments .

  7. 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.






share|improve this answer





















  • I will try it. Thanks for very informative/applicable answer.
    – CYREX
    Dec 1 at 14:18










  • It worked at my home computer. I want to implement it at my office. I m using windows server 2008 as a server and i want to deploy this task to all my domain users. As every system has its own network card and source will be different for each computer. Is there anyway i can put universal source name for network disconnection or i have to go to each computer to create that task?
    – CYREX
    Dec 1 at 14:58










  • In that case you could switch the trigger from Basic to Custom. If you press new Event Filter and switch to "By source" you can select multiple sources. If you only have very few computer models you could check there event logs and see how the source is called and add them all.
    – User025
    Dec 1 at 15:07













up vote
1
down vote



accepted







up vote
1
down vote



accepted






According to this answer: https://superuser.com/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.




  1. Open Event Viewer and filter for Events with the ID 27 and level "Warning" under
    Windows Logs -> System.


  2. 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.

  3. Open Task Scheduler and create a new task.

  4. In the properties window that opens give the task an name.

  5. 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.

  6. Now go to the Actions tab a and create a new action. In the windows that opens select
    "Start a program" and enter rundll32.exe as program
    path and user32.dll,LockWorkStation as arguments .

  7. 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.






share|improve this answer












According to this answer: https://superuser.com/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.




  1. Open Event Viewer and filter for Events with the ID 27 and level "Warning" under
    Windows Logs -> System.


  2. 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.

  3. Open Task Scheduler and create a new task.

  4. In the properties window that opens give the task an name.

  5. 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.

  6. Now go to the Actions tab a and create a new action. In the windows that opens select
    "Start a program" and enter rundll32.exe as program
    path and user32.dll,LockWorkStation as arguments .

  7. 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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 1 at 14:04









User025

27310




27310












  • I will try it. Thanks for very informative/applicable answer.
    – CYREX
    Dec 1 at 14:18










  • It worked at my home computer. I want to implement it at my office. I m using windows server 2008 as a server and i want to deploy this task to all my domain users. As every system has its own network card and source will be different for each computer. Is there anyway i can put universal source name for network disconnection or i have to go to each computer to create that task?
    – CYREX
    Dec 1 at 14:58










  • In that case you could switch the trigger from Basic to Custom. If you press new Event Filter and switch to "By source" you can select multiple sources. If you only have very few computer models you could check there event logs and see how the source is called and add them all.
    – User025
    Dec 1 at 15:07


















  • I will try it. Thanks for very informative/applicable answer.
    – CYREX
    Dec 1 at 14:18










  • It worked at my home computer. I want to implement it at my office. I m using windows server 2008 as a server and i want to deploy this task to all my domain users. As every system has its own network card and source will be different for each computer. Is there anyway i can put universal source name for network disconnection or i have to go to each computer to create that task?
    – CYREX
    Dec 1 at 14:58










  • In that case you could switch the trigger from Basic to Custom. If you press new Event Filter and switch to "By source" you can select multiple sources. If you only have very few computer models you could check there event logs and see how the source is called and add them all.
    – User025
    Dec 1 at 15:07
















I will try it. Thanks for very informative/applicable answer.
– CYREX
Dec 1 at 14:18




I will try it. Thanks for very informative/applicable answer.
– CYREX
Dec 1 at 14:18












It worked at my home computer. I want to implement it at my office. I m using windows server 2008 as a server and i want to deploy this task to all my domain users. As every system has its own network card and source will be different for each computer. Is there anyway i can put universal source name for network disconnection or i have to go to each computer to create that task?
– CYREX
Dec 1 at 14:58




It worked at my home computer. I want to implement it at my office. I m using windows server 2008 as a server and i want to deploy this task to all my domain users. As every system has its own network card and source will be different for each computer. Is there anyway i can put universal source name for network disconnection or i have to go to each computer to create that task?
– CYREX
Dec 1 at 14:58












In that case you could switch the trigger from Basic to Custom. If you press new Event Filter and switch to "By source" you can select multiple sources. If you only have very few computer models you could check there event logs and see how the source is called and add them all.
– User025
Dec 1 at 15:07




In that case you could switch the trigger from Basic to Custom. If you press new Event Filter and switch to "By source" you can select multiple sources. If you only have very few computer models you could check there event logs and see how the source is called and add them all.
– User025
Dec 1 at 15:07


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1379966%2fauto-lock-winl-computer-if-ethernet-cable-is-removed-or-ethernet-signals-drop%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕