[SOLVED] Creating a package to modify the Windows registry

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
Minus
Messages: 13
Registration: August 2, 2019 - 9:05 AM

February 20, 2020 - 10:59

Good morning

I would like to use Wapt to deploy a modification to a key in the Windows registry related to Outlook settings on certain PCs

My basic .reg file looks like this:

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\AutoDiscover]
"ExcludeExplicitO365Endpoint"=dword:00000001
So I created two batch files as follows:

The first one is to install the key (AntiPopup.bat):

Code: Select all

@echo off
REG ADD HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\AutoDiscover /f /v ExcludeExplicitO365Endpoint /t REG_DWORD /d "00000001"
The second one is to remove the key (RemoveAntiPopup.bat)

Code: Select all

@echo off
REG DELETE HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\AutoDiscover /v ExcludeExplicitO365Endpoint /f
Initially, I tested the batch files in a VM, and they worked without any problems

However, once the WAPT package is created with the following setup.py:

Code: Select all

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

uninstallkey = []

def install():
    print('AntiPopup.bat: Execute...')
    run(r'AntiPopup.bat')

def uninstall():
    print('RemoveAntiPopup.bat: Execute...')
    run(r'RemoveAntiPopup.bat')
The installation proceeds without error, but the key is not created in the VM.

Thinking there might be a problem with the application of a batch file, I converted the batch files into exe files with admin rights.

I tested the executable files directly in the VM; they create and delete the key correctly

I created the setup.py file as follows:

Code: Select all

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

uninstallkey = []

def install():
    print('AntiPopup.exe: Execute...')
    run(r'AntiPopup.exe')

def uninstall():
    print('RemoveAntiPopup.exe: Execute...')
    run(r'RemoveAntiPopup.exe')
And there, the same problem as before: the package runs fine without error, but the .exe file doesn't apply, as if it weren't running

Can you help me please? I have quite a few small packages like this to create.

Thank you in advance

### Required Information###
Server running Debian 9
Windows 10 Pro Admin Machine (1909)
WAPT Server version: 1.8.1
WAPT Agent version: 1.8.1.6740
WAPT Setup version: 1.8.1.6740
WAPT Deploy version: 1.8.1.6740
Database status: OK (1.7.6.6)
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

February 20, 2020 - 1:46 PM

Hello,

It's simpler with the right function: https://www.wapt.fr/fr/doc/wapt-create- ... gistry-key

Alexandre
Minus
Messages: 13
Registration: August 2, 2019 - 9:05 AM

February 20, 2020 - 2:02 PM

As a beginner learning Python, is this type of simple setup.py file suitable?

Code: Select all

# -*- coding: utf-8 -*-
from setuphelpers import *
 
registry_setstring(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Office\\16.0\\Outlook\\Autodiscover",'ExcludeExplicitO365Endpoint','00000001', type=REG_DWORD)
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

February 20, 2020 - 2:11 PM

So I just got a reprimand from my colleague; it's an HKCU key, so it can't be modified in the system context, only in the user context! (Thanks, Simon)

The correct answer is:

Code: Select all

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

uninstallkey = []

def install():
    pass

def uninstall():
    pass
    
def session_setup():
    registry_setstring(HKEY_CURRENT_USER, r"SOFTWARE\Microsoft\Office\16.0\Outlook\Autodiscover",'ExcludeExplicitO365Endpoint',1, type=REG_DWORD)
To understand how session_setup() works: https://www.wapt.fr/fr/doc/wapt-create- ... nvironment

First, you need to install the package > then run the command

Code: Select all

wapt-get session-setup ALL
on the workstation to execute the session_setup function

Alexander
Minus
Messages: 13
Registration: August 2, 2019 - 9:05 AM

February 20, 2020 - 2:17 PM

Thank you very much for the information, and sorry for causing a reprimand. :?

Okay for the `wapt-get session-setup ALL` command; it's easy to run via a GPO.

So, if it were an HKLM key? What should the setup.py file look like?
User avatar
agauvrit
WAPT Expert
Messages: 238
Registration: Nov 17, 2016 - 10:25
Location: Nantes
Contact :

February 20, 2020 - 5:47 PM

For HKLM > system context

Code: Select all

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

uninstallkey = []

def install():
    registry_setstring(HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Office\16.0\Outlook\Autodiscover",'ExcludeExplicitO365Endpoint',1, type=REG_DWORD)
    
Minus
Messages: 13
Registration: August 2, 2019 - 9:05 AM

February 21, 2020 - 09:17

Great!

Thank you so much for all this information.
Locked