[SOLVED] Registry key added but error returned

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
User avatar
Jerome
Messages: 8
Registration: August 7, 2020 - 8:09 AM
Location: Abbeville

June 11, 2021 - 08:33

Good morning,

Following the installation of Adobe Reader XI for compatibility reasons with one of our software programs, I wish to disable protected mode by adding registry keys.
I retrieve all the Windows session SIDs and loop through them to inject the key into each session.
Everything seems to be working; I have my keys correctly in my registry, but here's the console output that shows my system is showing an error. I don't understand why:
*** Remote Interpreter Reinitialized ***
Command line: install "c:\waptdev\wapt-adobe-XI-wapt\WAPT\.."
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Installing WAPT files c:\waptdev\wapt-adobe-XI-wapt
2021-06-10 15:35:17,161 CRITICAL Fatal error in install script: 22: Incorrect parameter:
Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 261, in reg_openkey_noredir
result = winreg.OpenKey(rootkey, subkeypath, 0, sam | winreg.KEY_WOW64_64KEY)
FileNotFoundError: [WinError 2] The specified file was not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\common.py", line 3910, in install_wapt
exitstatus = setup.install()
File "c:\waptdev\wapt-adobe-XI-wapt\setup.py", line 25, in install
registry_setstring(HKEY_USERS,r"%s\Software\Adobe\Acrobat Reader\11.0\TrustManager" %profsid,"iProtectedView",0, type=REG_DWORD)
File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 302, in registry_setstring
with reg_openkey_noredir(root, path, sam=KEY_WRITE, create_if_missing=True) as key:
File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 269, in reg_openkey_noredir
return winreg.CreateKeyEx(rootkey, subkeypath, 0, sam | winreg.KEY_READ | winreg.KEY_WOW64_64KEY | winreg.KEY_WRITE)
OSError: [WinError 87] Invalid parameter

FATAL ERROR: 22: Incorrect parameter
Exit code: 3
Here is the code snippet:
profiles_path = r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
for profsid in reg_enum_subkeys(reg_openkey_noredir(HKEY_LOCAL_MACHINE,profiles_path)):
if not profsid.startswith('S-1-5-21-'):
continue

registry_setstring(HKEY_USERS,r"%s\Software\Adobe\Acrobat Reader\11.0\TrustManager" %profsid,"iProtectedView",0, type=REG_DWORD)
registry_setstring(HKEY_USERS,r"%s\Software\Adobe\Acrobat Reader\11.0\TrustManager" %profsid,"bEnhancedSecurityStandalone",0, type=REG_DWORD)
registry_setstring(HKEY_USERS,r"%s\Software\Adobe\Acrobat Reader\11.0\TrustManager" %profsid,"bEnhancedSecurityInBrowser",0, type=REG_DWORD)
registry_setstring(HKEY_USERS,r"%s\Software\Adobe\Acrobat Reader\11.0\Privileged" %profsid,"bProtectedMode",0, type=REG_DWORD)
Wapt installation information:
Debian Server
wapt version 2.0
Administration machine: Windows 10 1909 x64
---
Jérôme
CH-Abbeville
florentR2
Messages: 100
Registration: February 13, 2020 - 5:23 PM

June 11, 2021 - 11:50

Wouldn't it be simpler to use session_setup() to write to the HKCU at session opening?.
User avatar
Jerome
Messages: 8
Registration: August 7, 2020 - 8:09 AM
Location: Abbeville

June 11, 2021 - 12:39

Indeed, it's better this way, cleaner and no error message.
THANKS.
def session_setup():

registry_setstring(HKEY_CURRENT_USER,"Software\\Adobe\\Acrobat Reader\\11.0\\TrustManager","iProtectedView",0, type=REG_DWORD)
registry_setstring(HKEY_CURRENT_USER,"Software\\Adobe\\Acrobat Reader\\11.0\\TrustManager","bEnhancedSecurityStandalone",0, type=REG_DWORD)
registry_setstring(HKEY_CURRENT_USER,"Software\\Adobe\\Acrobat Reader\\11.0\\TrustManager","bEnhancedSecurityInBrowser",0, type=REG_DWORD)
registry_setstring(HKEY_CURRENT_USER,"Software\\Adobe\\Acrobat Reader\\11.0\\Privileged","bProtectedMode",0, type=REG_DWORD)
---
Jérôme
CH-Abbeville
Locked