hits counter
Text to Speech for dyslexis disabilities

Support - Installer Syntax - Microsoft Active Setup - Software with a 90 days unlimited trial with all features installed

TryWare90Days.com
Don't waste hours, use minutes
Go to content

Main menu:

Support - Installer Syntax - Microsoft Active Setup

Deploying User Settings with Microsoft Active Setup in install ComputerScripts:

Does it work perfect - Yes and NO
It only works the first time - How can you solve the error 
When creating your ComputerScript to start an installation with ComputerSettings in C:\%ProgramFiles% and in HKLM registry, some vendors also need to apply UserSettings in C:\%UserProfile% or in HKCU registry.

If your end users isn't member of the local administrators group (as recommended by Microsoft), you are probably running your ComputerScript using a Management System running as a service with the local system account credentials, and if so  - you can't write to the end users UserSettings with a ComputerScript, and you can't get access to ComputerSettings when running a UserScript started with the end users credentials by the end users loginscript.
In order to solve that, you can use Active Setup, that probably isn't supported by your Management System functions, but if a Management System tries to use Active Setup, it can't control what is happening, because Active Setup is only and totally "managed" as part of the Windows operating system.
You can with you ComputerScript create a UserScript, that Active Setup automatically runs with the end users credentials, when the end user logs on.

It works perfect, if you only need  to run your Active Setup ComputerScript once.

It doesn't work at all, if you need  to run it more than once:

  • Maybe you need to customize your script while debugging script errors.
  • Maybe your Service Desk needs to re-install the application using your Active Setup ComputerScript for the second time, after uninstalling the application, which an end user is complaining about, after it did work several months without any problems.
Active Setup doesn't deal with these two issues, so this is how it works!

To implement Active Setup, you need to use 2 registry keys: 
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{        }]
@="        "
"ComponentID"="        "
"IsInstalled"=dword:00000001
"Locale"="*"
"StubPath"="C:\\Windows\\System32\\wscript.exe \"C:\\Program Files\\        \\         \""
"Version"="10,0,0,0"
"ProductID"="        "
"ProductVersion"="v1.0"

When you create the above HKLM regkey settings, it could for "iTunes 11.1.0.126" be:

[HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{FC40A6B5-9902-4831-BDD9-1D712CB14FA0}]
@="ITUNES 11.1.0.126"
"ComponentID"="Apple iTunes 11.1.0.126_us.vbs"
"IsInstalled"=dword:00000001
"Locale"="*"
"StubPath"="C:\\Windows\\System32\\wscript.exe \"C:\\Program Files\\CapaInstaller\\Client\\Usersetup\\Apple iTunes 11.1.0.126\\v1.0\\Apple iTunes 11.1.0.126_us.vbs\""
"Version"="10,0,0,0"
"ProductID"="Apple iTunes 11.1.0.126"
"ProductVersion"="v1.0"

Please note the "Version"="10,0,0,0": If the HKCU Active Setup regkey exists, the "Version" number in the HKLM Active Setup regkey must be a higher number, than the simular "Version" number in the HKCU Active Setup regkey. Otherwise the "Stubpath" script won't run the next time a end user logs on.

After creating the above HKLM Active Setup regkey, you need to create and copy the "StubPath" UserScript to the folder specified in "StubPath".

You don't need to  - and should not -  create the simular HKCU Ative Setup regkey, because it's automatically created by the operating system using Active Setup, when the end user logs on, but only if you have created the HKLM Active Setup regkey, and the HKCU regkey will get the same number in the "Version" regkey:
 
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\Active Setup\Installed "Version"="10,0,0,0"
"Locale"="*"
"IsInstalled"=dword:00000000
"Version"="10,0,0,0"

Please note the "Version"="10,0,0,0" (explained above in the HKLM Active Setup regkey)

When a user logs on for the first time after the Active Setup have been activated in HKLM, the Windows operating system compares the HKLM Active Setup keys with the HKCU Active Setup keys (if it exists), and the Windows operating system automatically runs the "StubPath" executable, but only if the HKCU Active Setup keys is missing, or the "Version" number in HKCU is less than the HKLM "Version" number.

If  you have created the HKLM Active Setup regkey (shown above) with your install ComputerScript, and  it's the first time your script runs, the operating system will create the missing HKCU Active Setup regkey, with the same "Version" number in HKCU as in HKLM, to show that it will try to run your "StubPath" script (if it exists). That's why your Active Setup install ComputerScript won't run the "StubPath" script, when you run your Active Setup install ComputerScript again and again and again, if you need to test errors in your scripts.

When  you need to upgrade  the installer executable with a new install script, just create the install script as usual for the new version, and increment  the 
HKLM Active Setup "Version" registry key (it will use another ). The next time the end user logs on, the Active Setup will run the "StubPath" executable again for that user, but only if the HKCU Active Setup keys is missing or the "Version" number in HKCU is less than the HKLM "Version" number.
 
So if you have many different installer executables using different old and new upgraded versions, and many different users running your Active Setup installer ComputerScript, it's very difficult to be able to decide how to increment the HKLM Active Setup "Version" registry key, with the right "Version" number (that always will work). And it's very difficult to debug why it doesn't work, but there is a the solution for this.

How can you solve this scenario:

If you are using the CapaInstaller Management System, you have permission to use the Custom_Computer_Active_Setup() and the Custom_User_Active_Setup() CustomLib.cis functions, as long as you don't remove the © Copyright info: 

Function Custom_Computer_Active_Setup()
 
'  © Copyright 2015: J.Malmgren, www.tryware90days.com - Only works with CapaLib functions from www.capasystems.com
 '  Make sure _us.cis from ComputerJobs\Kit is updated on your client computer, and that _us.cis ALWAYS will run using Microsoft Active Setup
 '  This function MUST run as the last just before  Job_InstallationCompleted()

On Error Resume Next

 Const iForWriting = 2
 Const iForAppending = 8

 Dim oFso                    : Set oFso = CreateObject("Scripting.FileSystemObject")
 Dim oFh
 Dim sPackageGuid            : sPackageGuid = "{FC40A6B5-9902-4831-BDD9-1D712CB14FA0}"
 '  Change the above according to Job_ActivateUserSetup(), when you are scripting a new version!

 Dim sErrorJob              : sErrorJob = ": The regkey is missing!"
 Dim sIniActivate           : sIniActivate = "Custom_User_Active_Setup() activated by Custom_Computer_Active_Setup()"
 Dim sIniSection            : sIniSection = "[" & sPackageGuid & "]"
 Dim sIniInsertVersion
 Dim sItdDir                : sItdDir = "C:\ITD\ActiveSetup"
 Dim sItdActiveSetupIni     : sItdActiveSetupIni = sItdDir & "\ActiveSetup.ini"
 Dim sItdActiveSetupEnable  : sItdActiveSetupEnable = sItdDir & "\ActiveSetup.txt"
 Dim sMsiFile               : sMsiFile = gsPackageRoot & "\Kit\32\iTunes.msi"
 Dim sReason                : sReason = sMsiFile & " does not exist"
 Dim sRegHKLM               : sRegHKLM = "HKEY_LOCAL_MACHINE"
 Dim sRegHKLM_Key           : sRegHKLM_Key = "SOFTWARE\Microsoft\Active Setup\Installed Components\"
 Dim sRegKey
 Dim sRegValue
 Dim sRegVersion            : sRegVersion = "Version"
 Dim sThisFunctionName      : sThisFunctionName = "Custom_Computer_Active_Setup"
 Dim iAnt, iNum
 Dim bFound                 : bFound = False
 Dim bMustExist             : bMustExist = False
 Dim bStatus                : bStatus = True

  If bStatus Then bStatus = Job_WriteLog(sThisFunctionName, " -----> GUID = " & sPackageGuid & "  sMsiFile = " & sMsiFile & " <-----", bStatus, True)

  If bStatus Then bStatus = File_ExistDir(sItdDir, False)
  If bStatus And Not(gbValue) Then bStatus = File_CreateDirectory(sItdDir)

  If bStatus Then bStatus = File_ExistFile(sItdActiveSetupIni, False)
  If bStatus And NOT(gbValue) Then
         bStatus = File_CreateEmptyFile(sItdActiveSetupIni, False)
         bFound = True
       Else
         If bStatus Then bStatus = Ini_ExistEntry(sItdActiveSetupIni, sIniSection, sRegVersion, False)
         If bStatus And NOT(gbValue) Then bFound = True
  End if
  If bStatus And bFound = True Then
  '      bStatus = File_AppendToFile(sItdActiveSetupIni, "[LastGuid]")  '  The File_AppendToFile is currently not working, so:
         Set oFh = oFso.OpenTextFile(sItdActiveSetupIni, iForAppending)
         bStatus = oFh.WriteLine("[LastGuid]" & vbCrLf & "sLastGuid=" & vbCrLf  & vbCrLf)
         bStatus = oFh.WriteLine(sIniSection & vbCrLf & "sVersion=" & vbCrLf  & vbCrLf)
         If bStatus Then bStatus = Job_WriteLog(sThisFunctionName, "-----> sLastGuid= and sVersion= was added to " & sItdActiveSetupIni & " <-----", bStatus, True)
         If bStatus Then bStatus = oFh.Close
  End if

  If bStatus Then bStatus = Ini_ReadEntry(sItdActiveSetupIni, sIniSection, sRegVersion, False)
  If bstatus And gbValue Then
       sRegValue = gsValue
       iNum = InStr(1, LCase(sRegValue), LCase(","), vbTextCompare)    '  Maybe 10,0,0,0
       iAnt = iNum -1                                                  '  =1 (9), or =2 (99), or =3 (999)
       iNum = Int(Left(sRegValue, iAnt) + 1)                           '  Maybe 11
       sRegValue = String(iNum) & ",0,0,0"                             '  Maybe 11,0,0,0
       sRegKey = sRegHKLM_Key & "\" & sPackageGuid
       bStatus = Reg_SetString(sRegHKLM, sRegKey, sRegVersion, sRegValue)
       If bStatus Then bStatus = Job_WriteLog(sThisFunctionName, "-----> " & sRegValue & " was added to " & sRegKey & "\" & sRegVersion & " <-----", bStatus, True)
       If bStatus Then bStatus = File_ExistFile(sItdActiveSetupIni, False)
       If bStatus And NOT(gbValue) Then
            bStatus = File_CreateEmptyFile(sItdActiveSetupEnable, False)
            If bStatus Then bStatus = File_AppendToFile(sItdActiveSetupEnable, Now() & " " & sIniActivate)
       End if
  End if

  Custom_Computer_Active_Setup = bStatus
End Function

__________________________________________

Function Custom_User_Active_Setup()
 '  © Copyright 2015: J.Malmgren, www.trywaredk.com - Only works with CapaLib functions from www.capasystems.com
 '  Run _us.cis from ComputerJobs\Kit because "Microsoft Active Setup" is activated because of Custom_User_Active_Setup()
 '  This function MUST run before Job_InstallationStart()
 '  You could delete "HKCU\SOFTWARE\Microsoft\Active Setup\Installed Components\{FC40A6B5-9902-4831-BDD9-1D712CB14FA0}", but then you can not debug errors

 Dim sIniSection
 Dim sItdDir                : sItdDir = "C:\ITD\ActiveSetup"
 Dim sItdActiveSetupIni     : sItdActiveSetupIni = sItdDir & "\ActiveSetup.ini"
 Dim sErrorJob              : sErrorJob = "The script is canceled because sLastGuid does not exist in section [LastGuid]: " & sItdActiveSetupIni
 Dim sItdActiveSetupEnable  : sItdActiveSetupEnable = sItdDir & "\ActiveSetup.txt"
 Dim sPackageGuid
 Dim sRegHKCU               : sRegHKCU = "HKEY_CURRENT_USER"
 Dim sRegHKCU_Key           : sRegHKCU_Key = "SOFTWARE\Microsoft\Active Setup\Installed Components\"
 Dim sRegKey
 Dim sRegValue
 Dim sRegVersion            : sRegVersion = "Version"
 Dim sThisFunctionName      : sThisFunctionName = "Custom_User_Active_Setup"
 Dim iAnt, iNum
 Dim bMustExist             : bMustExist = False
 Dim bStatus                : bStatus = True

  If bStatus Then bStatus = File_ExistFile(sItdActiveSetupEnable, False)
  If bStatus And gbValue Then
       bStatus = Job_WriteLog(sThisFunctionName, " -----> Active Setup is enabled by Custom_Computer_Active_Setup() using " & sItdActiveSetupEnable & " <-----", bStatus, True)
       If bStatus Then bStatus = Ini_ReadEntry(sItdActiveSetupIni, "[LastGuid]", "sLastGuid", True)
       If bstatus And gbValue Then
                 sPackageGuid = gsValue
                 sRegKey = sRegHKCU_Key & "\" & sPackageGuid
                 If bStatus Then bStatus = Reg_GetString(sRegHKCU, sRegKey, sRegVersion, bMustExist)
                 If bStatus And gbValue Then sRegValue = gsValue
                 If bStatus Then bStatus = Job_WriteLog(sThisFunctionName, "-----> Found " & sRegVersion & " = " & sGetString & " <-----", bStatus, True)
                 iNum = InStr(1, LCase(sRegValue), LCase(","), vbTextCompare)  '  Maybe 10,0,0,0
                 iAnt = iNum -1                                                '  =1 (9), or =2 (99), or =3 (999)
                 iNum = Int(Left(sRegValue, iAnt) + 1)                         '   Maybe 11
                 sIniSection = "[" & sPackageGuid & "]"
                 If bStatus Then bStatus = Ini_WriteEntry(sItdActiveSetupIni, sIniSection, sRegVersion, String(iNum))
                 sRegValue = String(iNum) & ",0,0,0"                           '  Maybe 11,0,0,0
                 sRegKey = sRegHKCU_Key & "\" & sPackageGuid
                 bStatus = Reg_SetString(sRegHKCU, sRegKey, sRegVersion, sRegValue)
                 If bStatus Then bStatus = Job_WriteLog(sThisFunctionName, "-----> " & sRegValue & " is added to " & sRegKey & "\" & sRegVersion & " <-----", bStatus, True)
                 If bStatus And gbValue Then bStatus = File_DelFile(sItdActiveSetupEnable, True)
             Else
                 bStatus = Job_ErrorHandling(sThisFunctionName, "----- " & sErrorJob & " -----", 0)
         End if
     Else
          bStatus = Job_WriteLog(sThisFunctionName, "-----> Nothing to do with Active Setup: " & sRegKey & " does not exist <-----", bStatus, True)
  End if

  Custom_User_Active_Setup = bStatus
End Function


PLEASE NOTE: This isn't  an error in the CapaLib Management System's library functions, because it's the Microsoft operating system using Active Setup, that doesn't automatically increment the HKLM "Version" number, according to the HKCU "Version" number created (not by CapaLib, but) by the Microsoft operation system. 

SO: Always use the HKLM Active Setup increment scenario, even when you for the first time create a installer ComputerScript for a total new application, and you are about to beta-test your script, maybe because there is syntax errors in your "StubPath" UserScript. Otherwise it won't run again each time you change the syntax in your UserScript and tests it again and again, except if you manually upgrades the "Version" number in the HKLM Active Setup regkey on your test computer, or manually deletes the HKCU Active Setup regkey.
__________________________________________

The 32-bit Active Setup "StubPath" UserScript in HKLM\SOFTWARE\Wow6432Node\Microsoft\Active Setup are executed before  the 64-bit Active Setup entries in HKLM\Software\Microsoft\Active Setup. Maybe you think is a typing error here, but actually there wasn't, because:

For 64-bit operating systems, the 32-bit Active Setup regkeys are migrated  to:
          HKLM\SOFTWARE\Wow6432Node\Microsoft\Active Setup\Installed Components\%APPNAME%
     and
          HKCU\Software\Wow6432Node\Microsoft\Active Setup\Installed Components\%APPNAME%

Active Setup regkeys made by true 64-bit applications on a 64-bit operating system will be made to the locations:
          HKLM\Software\Microsoft\Active Setup\Installed Components\%APPNAME%
    and
          HKCU\Software\Microsoft\Active Setup\Installed Components\%APPNAME%

And since 32-bit applications are automatically redirected to the WOW6432Node areas of the registry, there is no need to change the way that Active Setup is implemented based on the bit version of the operating system.


The Active Setup has nothing with the Microsoft MSI installer to do (as selected in my example above), because Active Setup works with all  installers with either the installers ProductCode (GUID) or the installers ProductName.
Last updated: 14-10-2017
Contact        Privacy Policy        Site Statistics        Sitemap        Terms of use       
Back to content | Back to main menu