Friday 27 February 2015

Active Setup - Advance Application Packaging

Active Setup


  
Active setup is a process that runs automatically when a user logs in. Active Setup runs for every user belong to that domain\server\machine.

Registry key location :

"HKLM\Software\Microsoft\Active Setup\Installed Components\%APPLICATIONNAME%" &

"HKCU\Software\Microsoft\Active Setup\Installed Components\%APPLICATIONNAME%"

If your application requires installation of 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.

To implement Active Setup, you need to package all your user installation requirements into an single installation or executable and point active setup to that executable and point this executable to StubPath entry in active path registry location.

If the HKCU Active Setup registry entry exist or the version number of HKCU is equal to HKLM, then the specified application is executed for the current user.

Ex
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\[ProductCode]]
"StubPath"="%Programdata%\Test\SelfExecute.exe"
"Version"="1,0"



Value for StubPath could be :
1. "%Programdata%\Test\SelfExecute.exe"
2. "msiexec /fpu [ProductCode] /qn"
3. "%Programdata%\Test\SelfExecute.vbs"

When each new user logs on, the operating system compares Active Setup keys between HKLM and HKCU, and runs the StubPath Instruction if the HKCU entry is missing or the version in HKCU is less than HKLM.
So if you ever need to update the ActiveSetup executable, just install a new version, and increment the Version registry key (VALUE2 above) in HKLM.Next time the user logs on, the active setup will run again for that user.

VBS to use versioning of the active setup :

Option Explicit
On Error Resume Next
Dim objShell,intVersion,strStubPath
Set objShell = CreateObject("WScript.Shell")
strStubPath = "msiexec /fou {Package-code} /qn"
objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{Package-code}_Install\StubPath", strStubPath , "REG_SZ"
intVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{Package-code}_Install\Version")
intVersion = intVersion + 1
objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{Package-code}_Install\Version", intVersion , "REG_SZ"
Set objShell = Nothing

This will increment the HKLM active Setup version by one and when user logsin next time Active setup will run again as HKCU Active Setup entry will have lesser version than HKLM.

I hope this post describe complete Active Setup fundamentals,
Please post your related query’s in comments so that we can add up more knowledge on it.

Thank you for reading.

1 comment:

  1. Nice explanation regarding Active Setup Procedure.... thanks for the info....keep posting realtime scenarios and solutions, it helps very much in understading the real time scenarios... :-)

    ReplyDelete