Windows auto lockout

Hi all,

i was wondering if a script exists that locks windows after X minutes and requires the user to enter password to get back in?

Hi @cccservices

Script to lock windows after X minutes and requires the user to enter password to get back in is completed.
refer the link below:
https://scripts.comodo.com/backend/web/topic/update/lock-the-system-if-it-is-inactive-for-more-than-the-time-limit-provided

Hi @cccservices

We are working on the script , we will update you once it is completed.

Thanks alot.

is that the script?
if so thanks, but where do I set the time? I can not seem to find “For example, threshold_time= x in seconds.” in the script.

https://scripts.comodo.com/frontend/web/topic/lock-the-system-if-it-is-inactive-for-more-than-the-time-limit-provided

Hi @cccservices

Sorry for the inconvenience, Please let me clarify one thing. Do you want to meet your X time with idle time ? or The script that should simply lock after X minutes which has provided ?

Thank you.

Sorry, after idle time equals X

Hi @cccservices

Please refer the following script to lock your workstation after idle time equals the threshold time.

https://scripts.comodo.com/frontend/web/topic/windows-auto-lockout

Thank you.

it does not seem to be locking the machines. it is rebooting them but thats it. I even set it to 60 and waited 30 minutes and still not locked

I check reg keys the first one has worked but the second has not. I ran this as system user and it said successful but as logged in user does not work

i did more searching it appears the second reg key does not exist in win10 pro (HKEY_CURRENT_USER, r’Software\Microsoft\Windows\CurrentVersion\Policies\System’, ‘ScreenSaveTimeOut’, REG_SZ, x)

Hi @cccservices

Sorry for your inconvenience.Please refer this script for auto lockout setting on your endpoint.Let us know your feedback.

Note:

  • Run as a System user.
  • This script will restart your system at the endpoint to apply change.
Edit parameters:
  • timeoff=120 #Minimum timeoff is 60 seconds. Provide timeoff only in seconds(should not be less than 60 seconds) as per your need.
Link: https://scripts.comodo.com/frontend/web/topic/windows-auto-lockout

Thank you

thanks for the quick reply. I must be doing something wrong as its not working on either win pro or home. It restarts the machine and the machine never locks. I did not change the script I run imported it and ran it. the logs even show successful.

hi @cccservices

I assume that the requirement for the script is to lock the windows when it is left undistrubed for a particular time.

Let me explain you step by step of the execution process

  1. idle time of the system is the time where there is no input from any input device like keyboard or mouse.

  2. Change the timeoff value in the script as per your requirement. remember the time off (greater than 60 seconds) should be in seconds.

             "timeoff=120     #Minimum time-off is 60 seconds
                                      #Provide time-off only in seconds(should not be less than 60 seconds)"
    
  3. Run the script, it will restart your system.

  4. The restart will update the display settings in your system.

  5. Once restart is over, login to your system.

  6. After login, leave the system without any interruption from mouse or keyboard for the time-off you mentioned.

  7. Once the time-off is reached the windows will lock automatically.

  8. For every time when you leave the system idle for the time-off you mentioned the windows will lock automatically.

i left the machine since 8am this morning and just came back to it and its not locked.

Hi @cccservices

We will check this and update you.

Thank You

Hi @cccservices

We modified the script to lock the windows when it is left undistrubed for a particular time.
Please follow the same procedure which have been instructed to you.

[I]Let me explain you step by step of the execution process

  1. idle time of the system is the time where there is no input from any input device like keyboard or mouse.

  2. Change the timeoff value in the script as per your requirement. remember the time off (greater than 60 seconds) should be in seconds.

“timeoff=120 #Minimum time-off is 60 seconds
#Provide time-off only in seconds(should not be less than 60 seconds)”

  1. Run the script, it will restart your system.

  2. The restart will update the display settings in your system.

  3. Once restart is over, login to your system.

  4. After login, leave the system without any interruption from mouse or keyboard for the time-off you mentioned.

  5. Once the time-off is reached the windows will lock automatically.

  6. For every time when you leave the system idle for the time-off you mentioned the windows will lock automatically.[/I]

Please refer the below script.
The JSON file of the script is also attached, if you want please refer it

timeoff=200 #Minimum timeoff is 60 seconds
            #Provide timeoff only in seconds(should not be less than 60 seconds)

import os
import ctypes
class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:
            self._revert(self.old_value)

with disable_file_system_redirection():
    try:
        cmd=os.popen('REG ADD "HKEY_CURRENT_USER\Control Panel\Desktop" /v "ScreenSaveTimeOut" /t REG_SZ /d %d /f'%timeoff).read()
    except:
        pass

print("The screensaver timeout setting is modified 
")
print ("The system will restart now ...... 
")
os.popen("shutdown  -r ").read()




20180213-Sleep.json (1.5 KB)

This script is still not working for me. I’ve tried it on Windows 7 and Windows 10 and the setting doesn’t apply on either. I’ve tried executing as the currently logged on user, and also the system user. Any ideas? I fully understand how this is supposed to work and it just doesn’t.

Hello @azon2111,

We appreciate for letting us know the result of your test. Our script developers would like to further investigate this matter hence it works perfectly in our environment under all possible conditions. We have created a support ticket for you and feel free to respond to the support ticket for the requested information. Thank you

any updates?