Home > Net >  MSI installer All User : Set value for SCRNSAVE.EXE
MSI installer All User : Set value for SCRNSAVE.EXE

Time:12-13

On my WPF program with MSI Installer, i need to set up HKCU\SCRNSAVE.EXE (and also ScreenSaveTimeOut, ScreenSaveActive and ScreenSaverIsSecure) registry key.

The problem is when i try to insert all this keys on registry via my MSI installer project (set to ALL User), my installer not create the keys.

I already try to install this key on HKLM but the configuration not apply on Windows.

Does there is a way to do this ?

Thank you :)

CodePudding user response:

Found a solution !

I loop into HKEY_USERS to add my registry key as i needed :)

RegistryKey lUsersKey = RegistryKey.OpenBaseKey(RegistryHive.Users, RegistryView.Registry64);

foreach (string lUsersSubKey in lUsersKey.GetSubKeyNames())
{
    try
    {
        RegistryKey lDesktopKey = lUsersKey.OpenSubKey(lUsersSubKey, true).CreateSubKey("Control Panel\\Desktop", true);
        lDesktopKey.SetValue("SCRNSAVE.EXE", myScrPath);
    }
    catch
    {
        continue;
    }
}
  • Related