1 Reply Latest reply on Feb 12, 2015 2:10 PM by klevitan

    Set-up a Query


      I wanted to see if anyone has set-up a Query to check and see if the Windows Automatic Updates is turned on?

        • 1. Re: Set-up a Query
          klevitan Specialist

          I do this in a 2 step process.  First I have a vbs script that will determine the status of autoupdate.  Its not a simple on or off.  And the location of the registry value controlling it depends on if it is set manually or is controlled by a group policy.

          I write the result to a registry key and then I have LANDesk collect that data (using custom data in Manage Software List).


          Here is the VBS script:


          Dim str, strKeyPath1, strKeyPath2, strOptionName, arrOptions
          strKeyPath1 = "HKLM\Software\Policies\Microsoft\Windows\WindowsUpdate\AU\"
          strKeyPath2 = "HKLM\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\"
          strOptionName = "AUOptions"
          arrOptions = array("Unknown", "Turn off", "Notify but do not download", "Download but do not install", "Automatic")

          str = ReadFromRegistry(strKeyPath1 & strOptionName, "0")
          'WScript.echo "WSUS AU: " & arrOptions(CInt(str))

          If str = "0" Then
          str = ReadFromRegistry(strKeyPath2 & strOptionName, "0")
          WriteReg "HKLM\Software\Huit\WinUpdates\AutoUpdate",arrOptions(CInt(str))
          ' WScript.echo "Auto Updates: " & arrOptions(CInt(str))
          WriteReg "HKLM\Software\Huit\WinUpdates\AutoUpdate",arrOptions(CInt(str)) & " (WSUS)"
          End If

          Function ReadFromRegistry (strRegistryKey, strDefault)
          Dim WSHShell, value
              On Error Resume Next
              Set WSHShell = CreateObject("WScript.Shell")
              value = WSHShell.RegRead(strRegistryKey)
              if err.number <> 0 then
                  ReadFromRegistry = strDefault
                  ReadFromRegistry = value
              end if
              set WSHShell = nothing
          End Function

          Sub WriteReg(strKeyPath,strValue)
            Dim WshShell, bKey
            Set WshShell = WScript.CreateObject("WScript.Shell")
            WshShell.RegWrite strKeyPath, strValue, "REG_SZ"
            Set wshShell = Nothing
          End Sub