Introduction

A common difficulty in desktop management is configuring per-user settings. Active Setup is a process that runs automatically every time a user logs in to a computer that can address this problem in a simple and flexible way.

If your application requires installation of components such as files or registry keys on a per-user basis, but your application has no advertised entry points or other triggers to initiate the installation process, then Active Setup is the solution.

When the user logs in the registry keys under HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\%APPNAME% are compared to the keys under HKEY_CURRENT_USER\Software\Microsoft\Active Setup\Installed Components\%APPNAME% and if the HKCU registry entries don’t exist, or the version number of HKCU is less than HKLM, then a specified command-line is executed for the current user.

To implement Active Setup, you simply create the required registry key and values under HKEY_LOCAL_MACHINE to execute the command-line that will apply all of the per-user requirements to the system. This could be an executable, an msiexec.exe command-line, regedit.exe, batch file, or any other executable command-line.

Note: Active Setup runs as the current user so it is not suitable for actions that require Administrator or other privileged security rights on the local computer.

Creating the Active Setup Registry Entries

Create the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\%APPNAME%

Where:

  • %APPNAME% is an arbitrary string which can be the application name, or its ProductCode GUID if using an MSI. This value should be unique to the application.

Create the following values under the registry key:

Name

Type

Data

Required

(Default)

REG_SZ

%APPNAME%

No

StubPath

REG_SZ

%COMMANDLINE%

Yes

Version

REG_SZ

%VERSION%

Yes

ComponentID

REG_SZ

%APPNAME%

No

Where:

  • %APPNAME% is the arbitrary application name specified above
  • %COMMANDLINE% is the command-line to execute
  • %VERSION% is an arbitrary version number to determine if Active Setup has run for the specific application

When each new user logs on, the operating system compares the Active Setup keys between HKLM and HKCU, and runs the specified command-line if the HKCU entry is missing or the version in HKCU is less than HKLM.

To re-run the same Active Setup or a new version of your per-user application settings, increment the Version registry value in HKLM. The next time the user logs on Active Setup will run again for that user.

An example exported registry file containing the key and values required to configure Active Setup is included below. Simply replace the variables with your required values.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\%APPNAME%]

@="%APPNAME%"

"StubPath"="%COMMANDLINE%"

"Version"="%VERSION%"

"ComponentID"="%APPNAME%"

Example registry file: Active_Setup_Example.reg

Example: Repairing An Existing MSI-Based Application

To force a repair using the existing MSI where a separate Active Setup executable is not required you could use the following example:

Create the registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\Active Setup\Installed Components\%PRODUCTCODE%

Under the registry key create the following values:

Name

Type

Data

Required

(Default)

REG_SZ

%APPNAME%

No

StubPath

REG_SZ

msiexec /fauvs %PRODUCTCODE% /qb

Yes

Version

REG_SZ

%VERSION%

Yes

ComponentID

REG_SZ

%APPNAME%

No

Where:

  • %PRODUCTCODE% is the MSI ProductCode GUID for the application.
Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • LinkedIn
  • Live
  • Twitter