DWORD registry value - prohibiting an executable

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
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

February 6, 2017 - 10:34

Good morning,
I'm having trouble adding a DWORD value to the registry; I get the following message when running session-setup:

CRITICAL ValueError: Could not convert the data to the specified type.


It's the same with the values ​​1 or 0x00000001.

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
import time
import os

uninstallkey = []

def GetUserName():
    return os.getenv('USERNAME')

def install():
    print('Installation de DisallowRun')

def session_setup():
    utilisateur = GetUserName()
    if(utilisateur == "eleve"):
        registry_set(HKEY_CURRENT_USER,r'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/','DisallowRun','0x00000001',type=REG_DWORD)
        registry_set(HKEY_CURRENT_USER,r'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/DisallowRun','1','shutdown.exe',type=REG_SZ)

Last edited by gaelds on 06 Feb 2017 - 11:25, edited 2 times.
User avatar
htouvet
WAPT Expert
Messages: 436
Registration: March 16, 2015 - 10:48
Contact :

February 6, 2017 - 10:46

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = []

def install():
    print('Installation de DisallowRun')

def session_setup():
    if (get_current_user() == "eleve"):
        registry_set(HKEY_CURRENT_USER,r'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/','DisallowRun',1,type=REG_DWORD)
        registry_set(HKEY_CURRENT_USER,r'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/DisallowRun','1','shutdown.exe',type=REG_SZ)
Tranquil IT
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

February 6, 2017 - 10:48

I just found another registry_set syntax in a message on the wapt mailing list and apparently it works:

Code: Select all

registry_set(HKEY_CURRENT_USER,r'Software/Microsoft/Windows/CurrentVersion/Policies/Explorer/', r'DisallowRun', 1, REG_DWORD)
Even after the shutdown.exe program is still not blocked for the student user, that's another problem...
Gaelds
Messages: 254
Registration: Nov 22, 2015 - 08:37

February 6, 2017 - 11:21

Ah sorry, our previous messages must have crossed paths, otherwise I tested another method with iCalcs to block access to shudown.exe.

Code: Select all

def session_setup():
    if (get_current_user() == "eleve"):
        print('interdiction de shutdown.exe pour eleve')
        run(r'takeown /F %windir%\system32\shutdown.exe')
        run(r'icacls %windir%\system32\shutdown.exe /deny eleve:D')
The command lines work in manual mode, but in session-setup, it has no effect, nor does it produce an error message.
Locked