Packaging VLC Player – Active Setup example

From ITNinja.com:

Active setup provides a solution when the aim is to deliver user based components when no advertised entry points exist in an MSI package.

Most packages will contain some kind on entry point; commonly an advertised shortcut. When launching this kind of shortcut Windows Installer will check the keypath of the component the shortcut belongs to and verifies that the component is installed. If it is found to be missing Windows Install will kick off a repair.

This provides a great solution for installing current user data when the package is not installed in the user context. It is also a very good reason why you should never mix machine and user data in the same feature.

So what do you do if there are no shortcuts to advertise? Active Setup will solve the problem.

An MSI package has been created to install an Outlook plug-in. This package installs both user and machine data. User preferences are stored as a combination of HKCU registry and an XML file written to %USERPROFILE%. As this application is a plug-in it does not contain any shortcuts. There are no other advertised entry points that might trigger a repair.

Further, this package is installed by the privileged account NTAUTHORITY\system. In this situation the user registry and XML file will be delivered to the Administrators profile and will never be installed for the user. This is when using active setup is appropriate.

Implementation
On logon the following registry keys are compared:

HKLM\Software\Microsoft\Active Setup\Installed Components\UID
HKCU\Software\Microsoft\Active Setup\Installed Components\UID

UID has to unique; it is good practise to use a GUID.

If the HKCU key is not found the contents of the string value StubPath is executed. The HKLM key is then copied to HKCU.

The executable in StubPath can be anything (a VBS script, a regsvr32.exe call, etc), but our aim, in this example, is to deliver missing current user data from a previously installed MSI. To do this we need to force the package to repair so Msiexec.exe will be used:

Msiexec.exe /fpu /qn

/f – Repair
/p – only if file is missing
/u – all required user-specific registry entries

If you choose to, the entire installation can be repaired:

Msiexec.exe /fauvs /qn

VLC Example

Active Setup is used for the VLC Player install to turn off automatic updates.

Download latest VLC player

Install the exe and run VLC. Turn off automatic updates. A vlcrc file is created in the user’s Roaming folder under the folder VLC. Copy that folder to your installation files folder. Add the vlc install exe to the folder as well.

The silent batch file install (install.bat) of vlc is:

:: Silent install of VLC

“%~DP0media\vlc-2.1.5-win32.exe” /L=1033 /S /NCRC

 :: Copy of the vlc settings file to the temp folder to be copied later by Active Setup

echo D | xcopy /q /y /s “%~DP0media\custom\vlc” “C:\Temp\vlc”

:: Copy of the exe that will be run by Active Setup to the logged-in users Roaming folder

echo F | xcopy /q /y “%~DP0media\custom\copy.exe” “C:\Temp\”

:: Installs into the registry the Active Setup keys that prompts the install of copy.exe

regedit.exe /s “%~DP0media\custom\VLC_ActiveSetup.reg”

 :: Deletes unnecessary shortcuts

Del “C:\Users\Public\Desktop\VLC media player.lnk”

Del “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\VideoLAN\Documentation.lnk”

Del “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\VideoLAN\Release Notes.lnk”

Del “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\VideoLAN\VideoLAN Website.lnk”

Copy.exe

This is actually a batch file converted to an exe by bat to exe converter. Download here:

http://www.f2ko.de/en/b2e.php

echo D | xcopy /q /y /s “C:\Temp\vlc” “%APPDATA%\vlc”

%AppData% resolves to the user’s Roaming folder:

C:\Users\<username>\AppData\Roaming

Use the converter to create Copy.exe from the batch file.

Active Setup

The reg key is saved as VLC_ActiveSetup.reg:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\VLC215]

“StubPath”=”C:\\temp\\copy.exe”

“Version”=”1”

“IsInstalled”=”1”

“ComponentID”=”VLC215”

Note the \\’s in the Stubpath – required for the exe to work. This method can be used for so many apps that need user profile files to be applied on login.

SCCM 

For the Application creation, make sure detection method is that vlc.exe exists in C:\Program Files (x86)\VideoLAN\VLC.

Set mandatory reboot to force the users to login if you wish.

Install:

install.bat

Uninstall:

 “C:\Program Files (x86)\VideoLAN\VLC\uninstall.exe” /S

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.