problem executing the session_setup() function
Published: September 29, 2025 - 5:30 PM
Good morning,
I have a package that needs to delete two values from a registry key (if those values exist) within the session_setup function. Here is the code:
Once the package is installed and when a user for whom both values in the key exist logs on, these two values are not deleted.
If I open a command prompt and manually run the session-setup function for this package, I get the following error:
However, if I open a command prompt with administrator privileges and run the session-setup function for this package, it executes successfully (I verify that the 2 values in the registry key are indeed deleted):
Where could the problem be coming from and is there a way to make the session-setup() function run automatically for each user when they log in?
I have a package that needs to delete two values from a registry key (if those values exist) within the session_setup function. Here is the code:
Code: Select all
def session_setup():
nom_PC=get_computername().lower()
if "pm" in nom_PC:
if reg_value_exists(HKEY_CURRENT_USER,'Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System','Wallpaper') :
registry_delete(HKEY_CURRENT_USER,'Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System','Wallpaper')
if reg_value_exists(HKEY_CURRENT_USER,'Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System','WallpaperStyle'):
registry_delete(HKEY_CURRENT_USER,'Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System','WallpaperStyle')
If I open a command prompt and manually run the session-setup function for this package, I get the following error:
Code: Select all
Microsoft Windows [version 10.0.26100.6584]
(c) Microsoft Corporation. Tous droits réservés.
U:\>wapt-get session-setup col73-pi-fonds-ecran
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Configuring col73-pi-fonds-ecran ...
Running session_setup for package col73-pi-fonds-ecran(=0-11) and user test
2025-09-29 17:12:08,371 CRITICAL Fatal error in session_setup function: AttributeError: __enter__:
Traceback (most recent call last):
File "C:\Program Files (x86)\wapt\waptpackage.py", line 3004, in call_setup_hook
hookdata = hook_func()
File "<string>", line 43, in session_setup
File "C:\Program Files (x86)\wapt\setuphelpers_windows.py", line 3862, in registry_delete
with reg_openkey_noredir(root, path, sam=KEY_WRITE) as key:
AttributeError: __enter__
2025-09-29 17:12:08,387 CRITICAL session_setup failed for package col73-pi-fonds-ecran(=0-11) and user test
Done
Code: Select all
Microsoft Windows [version 10.0.26100.6584]
(c) Microsoft Corporation. Tous droits réservés.
C:\Windows\System32>wapt-get session-setup col73-pi-fonds-ecran
Using config file: C:\Program Files (x86)\wapt\wapt-get.ini
Configuring col73-pi-fonds-ecran ...
Running session_setup for package col73-pi-fonds-ecran(=0-11) and user test
Done