Page 1 of 1
List of USER keys "S-1-5-21..." how to do it
Published: Dec 12, 2022 - 10:09
by Information Service
Hello everyone,
I'm trying to get the USER keys "S-1-5-21..." in 'HKEY_USERS' but I don't see how to do it.
Can you guide me?
Re: List of USER keys "S-1-5-21..." how to do it
Published: Dec 12, 2022 - 10:17
by Information Service
The goal is to manage user session locking and more
Re: List of USER keys "S-1-5-21..." how to do it
Published: Dec 12, 2022 - 11:29
by Information Service
Okay, I've found everything. If you see any improvements, I'm all ears
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
from setuphelpers_windows import *
uninstallkey = []
veille="600"
def install():
print("creation du tableau utilisateurs")
cles = run_powershell("reg query HKEY_USERS")
print("creation du tableau utilisateur OK")
print("traitement des lignes")
for i in cles:
if len(i) == 57:
racine = i[0:10]
user = i[11:57]
print("user traité "+user)
if racine == "HKEY_USERS":
print("modification des clés de registre")
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveActive", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaverIsSecure", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveTimeOut", veille, type=REG_SZ)
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "SCRNSAVE.EXE", "C:\WINDOWS\system32\scrnsave.scr", type=REG_SZ)
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveActive", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaverIsSecure", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveTimeOut", veille, type=REG_SZ)
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "SCRNSAVE.EXE", "C:\WINDOWS\system32\scrnsave.scr", type=REG_SZ)
Re: List of USER keys "S-1-5-21..." how to do it
Published: Dec 12, 2022 - 2:39 PM
by Information Service
Correction made to user search
Code: Select all
# -*- coding: utf-8 -*-
from setuphelpers import *
from setuphelpers_windows import *
uninstallkey = []
veille="600"
def install():
print("creation du tableau utilisateurs")
cles = run_powershell("reg query HKEY_USERS")
print(cles)
print("creation du tableau utilisateur OK")
print("traitement des lignes")
for i in cles:
i2 = i.split("\\")
print("tableau split")
print(i2)
print("-----verification des variables")
racine=i2[0]
if racine != '':
if "_Classes" not in i:
user=i2[1]
print(racine)
print(user)
if len(user) > 10:
print("user traité "+user)
if racine == "HKEY_USERS":
print("modification des clés de registre")
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveActive", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaverIsSecure", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveTimeOut", veille, type=REG_SZ)
registry_setstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "SCRNSAVE.EXE", "C:\WINDOWS\system32\scrnsave.scr", type=REG_SZ)
print(r"Fin du traitement de l'utilisateur "+user)
print("Fin des modifications utilisateurs")
print("Modification des valeurs default user")
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveActive", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaverIsSecure", "1", type=REG_SZ)
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveTimeOut", veille, type=REG_SZ)
registry_setstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "SCRNSAVE.EXE", "C:\WINDOWS\system32\scrnsave.scr", type=REG_SZ)
print("Fin des modification des valeurs default user")
def audit():
auditverif="OK"
msgerror=[]
#Vérification des différentes clés
print("creation du tableau utilisateurs")
cles = run_powershell("reg query HKEY_USERS")
print("creation du tableau utilisateur OK")
print("traitement des lignes")
for i in cles:
i2 = i.split("\\")
print("tableau split")
print(i2)
print("-----verification des variables")
racine=i2[0]
if racine != '':
if "_Classes" not in i:
user=i2[1]
print(racine)
print(user)
if len(user) > 10:
print("user traité "+user)
if racine == "HKEY_USERS":
print("modification des clés de registre")
if(registry_readstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveActive"))!="1":auditverif="ERROR" and msgerror.append(user+" ScreenSaveActive")
if(registry_readstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaverIsSecure"))!="1":auditverif="ERROR" and msgerror.append(user+" ScreenSaverIsSecure")
if(registry_readstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveTimeOut"))!=veille:auditverif="ERROR" and msgerror.append(user+" ScreenSaveTimeOut")
if(registry_readstring(HKEY_USERS, r''+user+'\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "SCRNSAVE.EXE"))!="C:\WINDOWS\system32\scrnsave.scr":auditverif="ERROR" and msgerror.append(user+" SCRNSAVE.EXE")
if(registry_readstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveActive"))!="1":auditverif="ERROR" and msgerror.append(user+" ScreenSaveActive")
if(registry_readstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaverIsSecure"))!="1":auditverif="ERROR" and msgerror.append(user+" ScreenSaverIsSecure")
if(registry_readstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "ScreenSaveTimeOut"))!=veille:auditverif="ERROR" and msgerror.append(user+" ScreenSaveTimeOut")
if(registry_readstring(HKEY_USERS, r'.DEFAULT\SOFTWARE\Policies\Microsoft\Windows\Control Panel\Desktop', "SCRNSAVE.EXE"))!="C:\WINDOWS\system32\scrnsave.scr":auditverif="ERROR" and msgerror.append(user+" SCRNSAVE.EXE")
print(auditverif)
print(msgerror)
print("renvoi du résultat d'audit")
if auditverif=="OK":return "OK"
if auditverif=="ERROR":return "ERROR"
Re: List of USER keys "S-1-5-21..." how to do it
Published: Dec 13, 2022 - 11:14
by t.heroult
At one point, I wanted to use a script of this kind to modify individual settings of the Windows storage assistant.
It looked like this:
Code: Select all
HKUSERS =winreg.OpenKey( winreg.HKEY_USERS, '',0, winreg.KEY_READ)
subKeys = winreg.QueryInfoKey(HKUSERS)
nbSubkeys = subKeys[0]
i = 0
while i < nbSubkeys:
#Modifications appliquées à tous les utilisateurs
subKey = winreg.EnumKey(HKUSERS,i)
if (subKey != ".DEFAULT"):
#Reglage OneDrive
key = winreg.CreateKey( winreg.HKEY_USERS, subKey + '\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\StorageSense\\Parameters\\StoragePolicy')
winreg.SetValueEx(key, '01', 0, winreg.REG_DWORD, 1)
winreg.SetValueEx(key, '04', 0, winreg.REG_DWORD, 1)
winreg.SetValueEx(key, '256', 0, winreg.REG_DWORD, 30)
winreg.SetValueEx(key, '512', 0, winreg.REG_DWORD, 60)
winreg.SetValueEx(key, '2048', 0, winreg.REG_DWORD, 1)
winreg.CloseKey(key)
i += 1
Re: List of USER keys "S-1-5-21..." how to do it
Published: Dec 13, 2022 - 12:03 PM
by Information Service
Thanks for the feedback.
So, if you don't do it that way, what do you use?
Re: List of USER keys "S-1-5-21..." how to do it
Published: Dec 13, 2022 - 12:41
by t.heroult
I chose to use session-setup. This way, when a user logs in after the package has been installed, the settings are instantly applied to their profile.
Furthermore, this will also apply to future users.