Windows automatic screen lock feature consultation
System: Windows 10
Architecture: x86_64
Question: I am using Python to write a Windows baseline detection script (by checking the registry), and if it does not meet the requirements, a repair function is provided (by modifying the registry). I encountered a problem in the lock screen setting repair baseline. I set the registry key value (turn on automatic lock screen), and the function also took effect (automatic lock screen after timeout), but the Windows settings interface still shows that the lock screen is not turned on.
Registry to detect and set:
ScreenSaveActive, ScreenSaverIsSecure, ScreenSaveTimeOut keys under HKEY_USERS\sid\Control Panel\Desktop
// sid is obtained through whoami /user
Operation steps:
- The python script detects the corresponding registry value to determine whether automatic screen lock is enabled
- If not enabled, the python script modifies the registry value
- Manually check that the registry has been modified
- Quietly wait for the timeout to confirm that the lock screen is effective
- Right-click on the desktop->Personalization->Lock screen interface->Screen saver settings, and it is found that it is not enabled
- Restart the computer and repeat step 5, the same result
Post a post to consult how to achieve python repair of the registry, and the windows settings interface also follows the registry changes.