3 Replies Latest reply on Jul 12, 2016 12:43 PM by dherder

    Custom Inventory does not return inventory results using the System account user execution context on Windows 10 computers

    william.drain@glazers.com Apprentice

      Has anybody successfully got Custom Inventory to return results on Windows 10 computers using a vbs script executing under the System account user context


      sample VBS script...


      On Error Resume Next

      Const strComputer = "."
      Const HKLM        = &H80000002
      'Const strKeyPath  = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"


      Dim oReg, arrSubKeys, strProduct, strDisplayName, strVersion, strKeyPath
      DIM WshShell : Set WshShell = CreateObject("WScript.Shell")
      DIM OsType : OsType = WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE") 

            If OsType = "x86" then 
                 strKeyPath  = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" 
            elseif OsType = "AMD64" then 
                 strKeyPath  = "SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"
            end if

      Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
           strComputer & "\root\default:StdRegProv")

      ' Enumerate the subkeys of the Uninstall key
      oReg.EnumKey HKLM, strKeyPath, arrSubKeys
      For Each strProduct In arrSubKeys
        ' Get the product's display name
        oReg.GetStringValue HKLM, strKeyPath & "\" & strProduct, "DisplayName", strDisplayName
        ' Process only products whose name contain 'Java'
        If InStr(1, strDisplayName, "java", vbTextCompare) > 0 and InStr(1, strDisplayName, "java auto update", vbTextCompare) < 1 Then
          ' Get the product's display version
          oReg.GetStringValue HKLM, strKeyPath & "\" & strProduct, "DisplayVersion"
          WScript.Echo strDisplayName & vbTab & strVersion
        End If