Re: Application-installation registry nightmares

From: Erwin Richard (erwin@richard.net)
Date: 04/11/02


From: "Erwin Richard" <erwin@richard.net>
Date: Thu, 11 Apr 2002 17:16:25 +0200


"David White" <will@not.give.email> wrote in message
news:y86t8.1106$56.118825@nasal.pacific.net.au...
> I need to write an installer to install an application on Windows NT, 2000
> or XP. The application was originallly written for Win 95. It reads and
> writes the registry quite a bit, but always within LOCAL_MACHINE. Under
NT,
> it cannot write to the registry without admin rights, so I need to do
> something about it. There are two ways, one good, the other horrible:
>
> 1. Fix up the application to use CURRENT_USERS, where appropriate, instead
> of LOCAL_MACHINE. The problem I'm having is: how does the installer set up
> the registry so that all the default registry keys and values will be
there
> when any user runs the application for the first time? I've tried putting
> everything under USERS\.DEFAULT. This works under Win 98, but under NT it
> only works for users that are added after the software is installed. It
> doesn't work for _existing_ users that log in and want to use the
software.
> It has to work for everyone, old or new, who might log in and want to use
> the application.

>
> 2. Leave everything in LOCAL_MACHINE and get the installer to change the
> registry permissions for the application's root key so that even the
> lowliest user has read/write permission. Yes, it's horrible, but might be
> needed as a quick fix until I can do it properly. I've tried to find out
how
> to do this in C++, but things are happening that I don't understand. After
> InstallShield adds all the registry info, I've tried this (with all but
the
> bare minimum code removed):
>
> SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
> lRetCode = RegSetKeySecurity(
> hKey,
> (SECURITY_INFORMATION)DACL_SECURITY_INFORMATION,
> &sd);
>
> This replaces all of the key's existing permissions with Everyone. But the
> root key's subkeys do not inherit the permissions. I have no idea, in C++,
> how to get the subkeys to inherit permissions. Also, I'd rather _add_
> Everyone, not replace the default permissions with it. To do that I tried
> this:
>
> DWORD size = 1; char data; // start by just finding out the size needed
> lRetCode = RegGetKeySecurity(hKey, DACL_SECURITY_INFORMATION, &data,
> &size);
>
> But this returns error 5 (Access Denied), not ERROR_INSUFFICIENT_BUFFER. I
> don't understand that. I'm logged in as Admin, I can change what I like in
> REGEDT32.EXE, but if I run a program that tries to read the registry key,
it
> denies permission. Yet, it allows me to _change_ the key's permissions to
> Everyone.
>
> I've looked at a sample program (check_sd.cpp), but I can't see from that
> where I'm going wrong.
>
> Can someone offer assistance?
>
> David
>

Suggestion:

- Use the Microsoft Installer Service to install the application
- During Installation you can only write to LOCAL_MACHINE (in the context
of Installer Service)
- Rewrite the Application to store user specific settings under CURRENT_USER
   provide defaults for these values either hardcoded or in LOCAL_MACHINE
but
   let CURRENT_USER settings override.

Changing the permissions in LOCAL_MACHINE is a bad idea because:

- It does not conform to standard expected behaviour
- If several users work on the same machine, they probably want different
user settings for each user.
- network administrators will not like your application
- security risk - depending on the information you want to store



Relevant Pages

  • Re: Why does Office go through Configuration routine every time?
    ... I then reapplied the registry updates, ... are registry keys whose permissions need changing. ... A Windows Installer shortcut provides two key features ... When a Microsoft Office program is activated, the Windows Installer ...
    (microsoft.public.office.setup)
  • Re: Why does Office go through Configuration routine every time?
    ... I then reapplied the registry updates, ... are registry keys whose permissions need changing. ... A Windows Installer shortcut provides two key features ... When a Microsoft Office program is activated, the Windows Installer ...
    (microsoft.public.office.setup)
  • Re: Why does Office go through Configuration routine every time?
    ... I then reapplied the registry updates, ... are registry keys whose permissions need changing. ... A Windows Installer shortcut provides two key features ... When a Microsoft Office program is activated, the Windows Installer ...
    (microsoft.public.office.setup)
  • Re: W2003 SP2 wont install - "Access is denied"
    ... permission on the HKCR\.ivf key as it had no permissions set. ... Reboot machine. ... Now I find that the installer program changes the LogLevel registry value to ...
    (microsoft.public.windowsupdate)
  • Re: Why does Office go through Configuration routine every time?
    ... There is a 'trick' that can shorten the process of repairing registry ... are registry keys whose permissions need changing. ... A Windows Installer shortcut provides two key features ... When a Microsoft Office program is activated, the Windows Installer ...
    (microsoft.public.office.setup)