Dynamic application detection with Lite Touch, Revisited


Over a year ago, I posted a blog entry at http://blogs.technet.com/mniehaus/archive/2008/09/25/dynamic-application-detection-with-lite-touch.aspx with details on how to automatically detect installed applications during a Lite Touch deployment, enabling those to be pre-selected when the application list is presented.  Due to changes in the XML file schemas, this script needs some updates for MDT 2010 to be truly “correct”.  The updated script follows, showing how to create a user exit that leverages the ZTIConfigFile script to enumerate all the available (enabled, visible) applications.

Option Explicit

Function UserExit(sType, sWhen, sDetail, bSkip)

    Dim oScriptFile
    Dim oXMLApps, dAllApps
    Dim sGUID
    Dim oNode, oKey
    Dim sValueName, sKey, sValue
    Dim oApplications

    ‘ Only do this before processing the rule contents

    If sWhen <> "BEFORE" then
        UserExit = Success
        Exit Function
    End if

    ‘ Make sure ZTIConfigFile is loaded

    On Error Resume Next
    Set oScriptFile = oFSO.OpenTextFile(oUtility.ScriptDir & "\ZTIConfigFile.vbs", 1, false)
    ExecuteGlobal oScriptFile.ReadAll
    On Error Goto 0

    ‘ Load the applications XML File

    Set oXMLApps = new ConfigFile
    oXMLApps.sFileType = "Applications"
    Set dAllApps = oXMLApps.FindItems

    ‘ Enumerate the applications

    For each sGUID in dAllApps

        Set oNode = dAllApps(sGUID)

        ‘ Retrieve the uninstall key node if present

            Set oKey = oNode.selectSingleNode("UninstallKey")

        ‘ If one was specified, look for the key in the registry

        If not (oKey is nothing) then

            ‘ Get the key name

            sKey = oKey.Text

            ‘ Check if the registry key exists by looking for well-known values

            For each sValueName in Array("DisplayName", "UninstallString", "QuietUninstallString")

                sValue = empty
                On Error Resume Next
                sValue = oShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\" & sKey & "\" & sValueName)
                On Error Goto 0

                If IsEmpty(sValue) then
                    On Error Resume Next
                    sValue = oShell.RegRead("HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & sKey & "\" & sValueName)
                    On Error Goto 0
                End if

                ‘ If a value was found, add the application’s GUID to the list so it gets pre-selected by the wizard

                If not IsEmpty(sValue) then

                    oLogging.CreateEntry "Uninstall registry key found for application " & oNode.selectSingleNode("Name").Text & ", application is present and will be reinstalled.", LogTypeInfo

                    ‘ Add the GUID if it doesn’t already exist in the list

                    Set oApplications = oEnvironment.ListItem("Applications")
                    If not oApplications.Exists(oNode.Attributes.getNamedItem("guid").value) then
                        oApplications.Add oNode.Attributes.getNamedItem("guid").value, ""
                        oEnvironment.ListItem("Applications") = oApplications
                    End if

                    Exit For

                End if

            Next
        Else

            oLogging.CreateEntry "UninstallKey not specified for application " & oNode.selectSingleNode("Name").Text, LogTypeInfo

        End if

    Next

    UserExit = Success

End Function

The code has been updated some, but the concepts haven’t, so if you need more details on what this does check out the original article.


Comments (1)

  1. aw says:

    hai, I just want to tell you that I am just very new to blogs and seriously loved this website. More than likely I’m planning to bookmark your blog post .
    You amazingly come with really good posts. Thanks a lot for sharing your blog Microsoft.

    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Aceh
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bali
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Balikpapan
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bandung
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Banjarmasin
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Banten
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Batam
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bekasi
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bengkulu
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bogor
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bontang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cianjur
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cikarang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cilegon
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cirebon
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Denpasar
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Jakarta
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Jambi
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Jember
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Karawang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Kendal
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Kudus
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Kupang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Lampung
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Madiun
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Makasar
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Malang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Maluku
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Manado
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Medan
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20NTT
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Padang