List of USER keys "S-1-5-21..." how to do it

Questions about WAPT Packaging / Requests and help regarding Wapt packages.
Forum Rules
Community Forum Rules
* English support on www.reddit.com/r/wapt
* French community support is available on this forum
* Please prefix the topic title with [RESOLVED] if it is resolved.
* Please do not edit a topic that is tagged [RESOLVED]. Open a new topic referencing the old one.
* Specify the installed WAPT version, full version, and build number (2.2.1.11957 / 2.2.2.12337 / etc.) as well as the Enterprise/Discovery edition.
* Versions 1.8.2 and earlier are no longer supported. The only questions accepted regarding version 1.8.2 are related to upgrading to a supported version (2.1, 2.2, etc.).
* Specify the server OS (Linux/Windows) and version (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specify the OS of the administration/package creation machine and the machine with the problematic agent, if applicable (Windows 7/10/11/Debian 11/etc.).
* Avoid asking multiple questions when opening a topic, otherwise it may be ignored. If there are multiple topics, open separate topics, preferably one after the other and not all at the same time (i.e., do not spam the forum).
* Include code snippets, screenshots, and other images directly in the post. Links to Pastebin, Bitly, and other third-party sites will be systematically removed.
* As with any community forum, support is provided voluntarily by members. If you require commercial support, you can contact Tranquil IT's sales department at 02.40.97.57.55
Locked
Information service
Messages: 24
Registration: Sep 14, 2022 - 12:10

December 12, 2022 - 10:09 AM

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?
Information service
Messages: 24
Registration: Sep 14, 2022 - 12:10

December 12, 2022 - 10:17

The goal is to manage user session locking and more
Information service
Messages: 24
Registration: Sep 14, 2022 - 12:10

December 12, 2022 - 11:29

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)
Attachments
2022-12-12 11_30_52-Window.png
2022-12-12 11_30_52-Window.png (43.21 KB) Viewed 4571 times
Information service
Messages: 24
Registration: Sep 14, 2022 - 12:10

December 12, 2022 - 2:39 PM

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"
Attachments
2022-12-12 14_38_41-192.168.236.41 - Remote Desktop Connection.png
2022-12-12 14_38_41-192.168.236.41 - Remote Desktop Connection.png (62.25 KB) Viewed 4550 times
2022-12-12 11_30_52-Window.png
2022-12-12 11_30_52-Window.png (43.21 KB) Viewed 4550 times
User avatar
t.heroult
Messages: 307
Registration: December 8, 2020 - 10:13 AM

December 13, 2022 - 11:14

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 
Server: WAPT Enterprise 2.6.1.17786 on Debian
Consoles: Windows 10 & 11
Infrastructure: Windows

Did you know? When parrotfish undergo smoltification, their osmoregulation mechanism is reversed!
Information service
Messages: 24
Registration: Sep 14, 2022 - 12:10

December 13, 2022 - 12:03

Thanks for the feedback.

So, if you don't do it that way, what do you use?
User avatar
t.heroult
Messages: 307
Registration: December 8, 2020 - 10:13 AM

December 13, 2022 - 12:41

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.
Server: WAPT Enterprise 2.6.1.17786 on Debian
Consoles: Windows 10 & 11
Infrastructure: Windows

Did you know? When parrotfish undergo smoltification, their osmoregulation mechanism is reversed!
Locked