We have SCCM 2012 SP1, CU5 installed in our environment and are using the 
Application Model.  We have some questions in regards to the detection methods 
and the process works for the detection method.


1.       How can you troubleshoot and determine what SCCM is doing when a 
detection method is being executed on a machine?

2.       How do you determine why the detection method is failing?

3.       Is there a way to look at the DiscoverySourcexml to see what the 
detection returned?

4.       When a script is being used what is SCCM look for to ensure the script 
is successful?

We are using the vbscript below to try and detect if Adobe Flash is installed 
and we are getting a failed detection.  Any thoughts or assistance would be 
appreciated.

'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'//
'// VBScript: CheckInstalled.vbs
'// Purpose: This script searches the registry to determine if the specified 
software is already installed on the machine. Mainly to be used with SCCM
'//
'// Written by:
'// Last Modified: 03/30/2015
'//
'//
'// Usage:
'//                           This script is meant to be universal. Simply add 
the GUID, DisplayName, and DisplayVersion of the product(s) to the Array
'//                           ApplicationList separated by asteriks (*). Each 
product should be separated by the pipe character (|).
'//                           These values MUST match exactly what gets put in 
the registry. If they
'//                           do not the script will not return a success. See 
example:
'//
'// Example:
'//                           ApplicationList = 
"{68BC8140-3FAA-4419-B6EE-CCF60BE6DAB2}*Adobe Flash Player 16 
ActiveX*16.0.0.305|" & _
'//                           "{0311AB48-F3E7-4DEE-8E11-EB0DDF4D3624}*Internet 
Explorer 11*11.0|" & _
'//                           "{26A24AE4-039D-4CA4-87B4-2F03217076FF}*Java 7 
Update 76 (32-bit)*7.0.760|" & _
'//                           "{26A24AE4-039D-4CA4-87B4-2F06417076FF}*Java 7 
Update 76 (64-bit)*7.0.760"
'//
'// NOTE* If you just have one application to check just search for it:
'//                           ApplicationList = 
"{68BC8140-3FAA-4419-B6EE-CCF60BE6DAB2}*Adobe Flash Player 16 
ActiveX*16.0.0.305"
'//
'//
'//
'////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Option Explicit
Const HKEY_LOCAL_MACHINE = &H80000002
Dim ApplicationList
Dim ApplicationsArray
Dim Application
Dim AppInfoArray
Dim AppGuid
Dim AppDisplayName
Dim AppDisplayVersion
Dim DisplayName
Dim DisplayVersion
Dim ReturnDisplayName
Dim ReturnDisplayVersion


'======================================================================================================================================================
'Only Modify the ApplicationList
'Syntax: GUID*DisplayName*DisplayVersion|GUID*DisplayName*DisplayVersion


ApplicationList = "{8C901387-B304-404D-93C0-E2E0C2D53D90}*Adobe Flash Player 17 
ActiveX*17.0.0.134"



'Should be no need to modify anything below this
'======================================================================================================================================================



'Parse the application list into an array separating it by the pipe character
ApplicationsArray = Split ( ApplicationList, "|" )

For Each Application In ApplicationsArray
                'Parse the Application into the individual details separating 
by the asterik (*)
                AppInfoArray = Split ( Application, "*")
                AppGuid = AppInfoArray( 0 )
    AppDisplayName = AppInfoArray( 1 )
                AppDisplayVersion = AppInfoArray( 2 )

                'Check and verify that the key exists for each application. If 
at any time a test does not pass
                'then the all the conditions are not met and the application is 
not installed on the system so we quit
                if (KeyExists(AppGuid,ReturnDisplayName,ReturnDisplayVersion) = 
TRUE) Then
                                DisplayName = ReturnDisplayName
                                DisplayVersion = ReturnDisplayVersion
                                if DisplayVersion <> AppDisplayVersion Then
                                                'wscript.echo "FAIL: " + 
DisplayVersion + " does not equal " + AppDisplayVersion
                                                wscript.quit
                                elseif DisplayName <> AppDisplayName then
                                                'wscript.echo "FAIL: " + 
DisplayName + " does not equal " + AppDisplayName
                                                wscript.quit
                                Else
                                                'wscript.echo "AppFound:  GUID 
= " + AppGuid + "  DisplayName = " + DisplayName + "  DisplayVersion = " + 
DisplayVersion
                                end if
                Else
                                'wscript.echo "Key does not exist: " + AppGuid
                                wscript.quit
                End If
Next

'If we get past the loop then all conditions are true and the application is 
fully installed.
WScript.Echo "Success! Application is installed."

'----------------------------------------------------------------------------------------------------------------------------------------------------
' Function:KeyExists
' Purpose: Searches the uninstall portion of the registry for the key and 
returns the DisplayName and DisplayVersion
'----------------------------------------------------------------------------------------------------------------------------------------------------
Function KeyExists( GUID , ReturnDisplayName, ReturnDisplayVersion )
                Dim Key

                DisplayName = ""
                DisplayVersion = ""


                'Look for specified GUID in the registry (OSbit determines 
whether we look at 32-bit side or 64-bit side of the registry
                Key = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & 
GUID
                ReturnDisplayName = GetSoftwareInfo( HKEY_LOCAL_MACHINE, Key, 
"DisplayName", 32 )
                ReturnDisplayVersion = GetSoftwareInfo( HKEY_LOCAL_MACHINE, 
Key, "DisplayVersion", 32 )

                If ((ReturnDisplayName = "") and (ReturnDisplayVersion = "")) 
Then
                                If Is64Bit Then
                                                ReturnDisplayName = 
GetSoftwareInfo( HKEY_LOCAL_MACHINE, Key, "DisplayName", 64 )
                                                ReturnDisplayVersion = 
GetSoftwareInfo( HKEY_LOCAL_MACHINE, Key, "DisplayVersion", 64 )
                                                If ((ReturnDisplayName = "") 
and (ReturnDisplayVersion = "")) Then
                                                                KeyExists = 
False
                                                Else
                                                                KeyExists = True
                                                End If
                                Else
                                                KeyExists = FALSE
                                End If
                Else
                                KeyExists = TRUE
                End If
End Function

'----------------------------------------------------------------------------------------------------------------------------------------------------
' Function: GetSoftwareInfo
' Purpose: Reads a REG_SZ value from the local computer's registry using WMI.
' Parameters:
'   RootKey - The registry hive.
'   Key - The key that contains the desired value.
'   Value - The value that you want to get.
'   RegType - The registry bitness: 32 or 64.
'
' Notes:
'   The StdRegProv class allows us to access the 64-bit registry node from a 
32-bit app
'   http://msdn.microsoft.com/en-us/library/aa393067(v=vs.85).aspx
'----------------------------------------------------------------------------------------------------------------------------------------------------
Function GetSoftwareInfo( RootKey, Key, Value, RegType )
    Dim oCtx, oLocator, oReg, oInParams, oOutParams

    Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
    oCtx.Add "__ProviderArchitecture", RegType

    Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
    Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , 
oCtx).Get("StdRegProv")

    Set oInParams = oReg.Methods_("GetStringValue").InParameters
    oInParams.hDefKey = RootKey
    oInParams.sSubKeyName = Key
    oInParams.sValueName = Value

    Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)
                If oOutParams.ReturnValue = 0 Then
                                'WScript.Echo oOutparams.GetObjectText_
                                'WScript.Echo "UninstallString is set to  " & 
oOutparams.SValue
                                GetSoftwareInfo = oOutParams.sValue
                End If

                Set oCtx = Nothing
                Set oLocator = Nothing
                Set oReg = Nothing
                Set oInParams = Nothing
                Set oOutParams = Nothing
End Function

'----------------------------------------------------------------------------------------------------------------------------------------------------
' Function: Is64Bit()
' Purpose: Determine if OS is 64-bit or 32-bit
'----------------------------------------------------------------------------------------------------------------------------------------------------
Function Is64Bit()
                Is64Bit = False
                Dim colOS : Set colOS = 
GetObject("WinMGMTS://").ExecQuery("SELECT AddressWidth FROM Win32_Processor",, 
48)
                Dim objOS
                For Each objOS In colOS
                                If objOS.AddressWidth = 64 Then Is64Bit = True
                Next

                Set colOS = Nothing
End Function

Reply via email to