Application-installation registry nightmares

From: David White (will@not.give.email)
Date: 04/11/02


From: "David White" <will@not.give.email>
Date: Thu, 11 Apr 2002 12:03:53 +1000

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



Relevant Pages

  • Re: office update is unable to check for updates
    ... Windows Installer version 1.0 to Windows Installer version 1.1. ... Here is another post I saw on the forums that seems to have work for other users, but it requires advanced knowledge of the OS, basically registry editing, so please be careful if you try it. ... we need to manually delete all the registry keys for Office. ...
    (microsoft.public.officeupdate)
  • Fix for Office install fails and Install popups
    ... Tried the often suggested method of using the Windows Installer Cleanup ... aware that it involves a lot of registry editing, but it did fix ALL of my ... If you use Registry Editor ... Delete the following registry keys if they exist: ...
    (microsoft.public.office.setup)
  • RE: can not auto update office 2003
    ... Windows Installer information from the machine so you can reinstall it ... Please read it carefully as editing the registry can permanently damage your ... Delete the following registry keys if they exist: ... The keys and subkeys are listed in a folder tree in the ...
    (microsoft.public.officeupdate)
  • 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)