Solved

Need VBscript to check available updates on update.microsoft.com

Posted on 2008-06-13
11
684 Views
Last Modified: 2010-04-21
Need script to auto check update.microsoft.com and list available updates in a html file. Anyone can help?
0
Comment
Question by:Dutchict
  • 6
  • 5
11 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 21783381
Hi,

Couldn't you just browse to
http://windowsupdate.microsoft.com

and follow the prompts?

Otherwise, you could set up a WSUS Server to control the updates pushed to your organisation.
http://technet.microsoft.com/en-us/wsus/default.aspx

Regards,

Rob.
0
 

Author Comment

by:Dutchict
ID: 21793252
Hi Rob,
I just don't have the IQ to build a browse script to check the updates and put the feedback on my HTML output...
Can you help me?
0
 

Author Comment

by:Dutchict
ID: 21802528
Hi guys, i found this update check script, but i need to transform this into my already made html output script

I have replaced all (wscript.echo  ")  to  (strHTML = strHTML & VbCrLf & "<br>)
Anyone suggestions????
Set objSession = CreateObject("Microsoft.Update.Session")
Set objSearcher = objSession.CreateUpdateSearcher
Set objResults = objSearcher.Search("Type='Software'")
Set colUpdates = objResults.Updates
 
For i = 0 to colUpdates.Count - 1
    Wscript.Echo "Title: " & colUpdates.Item(i).Title
    Wscript.Echo "Autoselect on Web sites: " & colUpdates.Item(i).AutoSelectOnWebSites
    For Each strUpdate in colUpdates.Item(i).BundledUpdates
        Wscript.Echo "Bundled update: " & strUpdate
    Next
    Wscript.Echo "Can require source: " & colUpdates.Item(i).CanRequireSource
    Set objCategories = colUpdates.Item(i).Categories
 
    For z = 0 to objCategories.Count - 1
        Wscript.Echo "Category name: " & objCategories.Item(z).Name
        Wscript.Echo "Category ID: " & objCategories.Item(z).CategoryID
        For Each strChild in objCategories.Item(z).Children
            Wscript.Echo "Child category: " & strChild
        Next
        Wscript.Echo "Category description: " & objCategories.Item(z).Description
        Wscript.Echo "Category type: " & objCategories.Item(z).Type
    Next
 
    Wscript.Echo "Deadline: " & colUpdates.Item(i).Deadline
    Wscript.Echo "Delta compressed content available: " & _
        colUpdates.Item(i).DeltaCompressedContentAvailable
    Wscript.Echo "Delta compressed content preferred: " & _
        colUpdates.Item(i).DeltaCompressedContentPreferred
    Wscript.Echo "Description: " & colUpdates.Item(i).Description
    Wscript.Echo "EULA accepted: " & colUpdates.Item(i).EULAAccepted
    Wscript.Echo "EULA text: " & colUpdates.Item(i).EULAText
    Wscript.Echo "Handler ID: " & colUpdates.Item(i).HandlerID
 
    Set objIdentity = colUpdates.Item(i).Identity
    Wscript.Echo "Revision number: " & objIdentity.RevisionNumber
    Wscript.Echo "Update ID: " & objIdentity.UpdateID
 
    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    Wscript.Echo "Can request user input: " & objInstallationBehavior.CanRequestUserInput
 
    Select Case objInstallationBehavior.Impact
        Case 0
            Wscript.Echo "Installation impact: Typical"
        Case 1
            Wscript.Echo "Installation impact: Negligible"
        Case 2
            Wscript.Echo "Installation impact: High"
        Case Else
            Wscript.Echo "The installation impact could not be determined."
    End Select
 
    Select Case objInstallationBehavior.RebootBehavior
        Case 0
            Wscript.Echo "Reboot behavior: No reboot required after installation."
        Case 1
            Wscript.Echo "Reboot behavior: A reboot is required after installation."
        Case 2
            Wscript.Echo "Reboot behavior: A reboot might be required after installation."
        Case Else
            Wscript.Echo "Reboot behavior: No information available regarding the need for a reboot."
    End Select
 
    Wscript.Echo "Requires network connectivity: " & objInstallationBehavior.RequiresNetworkConnectivity
    Wscript.Echo "Is beta: " & colUpdates.Item(i).IsBeta
    Wscript.Echo "Is hidden: " & colUpdates.Item(i).IsHidden
    Wscript.Echo "Is installed: " & colUpdates.Item(i).IsInstalled
    Wscript.Echo "Is mandatory: " & colUpdates.Item(i).IsMandatory
    Wscript.Echo "Is uninstallable: " & colUpdates.Item(i).IsUninstallable
    For Each strLanguage in colUpdates.Item(i).Languages
        Wscript.Echo "Supported language: " & strLanguage
    Next
 
    Wscript.Echo "Last deployment change time: " & colUpdates.Item(i).LastDeploymentChangeTime
    Wscript.Echo "Maximum download size: " & colUpdates.Item(i).MaxDownloadSize
    Wscript.Echo "Minimum download size: " & colUpdates.Item(i).MinDownloadSize
    Wscript.Echo "Microsoft Security Response Center severity: " & colUpdates.Item(i).MsrcSeverity
    Wscript.Echo "Support URL: " & colUpdates.Item(i).SupportURL
 
    Select Case colUpdates.Item(i).Type
        Case 1
            Wscript.Echo "Update type: Software"
        Case 2
            Wscript.Echo "Update type: Driver"
       Case Else
            Wscript.Echo "Update type: The update type could not be determined."
    End Select
 
    Wscript.Echo "Uninstallation notes: " & colUpdates.Item(i).UninstallationNotes
 
    x = 1
    For Each strStep in colUpdates.Item(i).UninstallationSteps
        Wscript.Echo x & " -- " & strStep
        x = x + 1
    Next
 
    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        Wscript.Echo "KB article: " & strArticle
    Next
 
    Wscript.Echo
 
Next

Open in new window

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Dutchict
ID: 21811207
Atached is the latest code, don't know why, but i get a blanc page in return...

On Error Resume Next
 
 
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
 
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("Type='Software'")
Set colUpdates = objResults.Updates
 
For i = 0 to colUpdates.Count - 1
    strHTML = strHTML & VbCrLf & "<br>Title: " & colUpdates.Item(i).Title
    strHTML = strHTML & VbCrLf & "<br>Autoselect on Web sites: " & _
        colUpdates.Item(i).AutoSelectOnWebSites
 
    For Each strUpdate in colUpdates.Item(i).BundledUpdates
        strHTML = strHTML & VbCrLf & "<br>Bundled update: " & strUpdate
    Next
    strHTML = strHTML & VbCrLf & "<br>Can require source: " & colUpdates.Item(i).CanRequireSource
    Set objCategories = colUpdates.Item(i).Categories
 
    For z = 0 to objCategories.Count - 1
        strHTML = strHTML & VbCrLf & "<br>Category name: " & objCategories.Item(z).Name
        strHTML = strHTML & VbCrLf & "<br>Category ID: " & objCategories.Item(z).CategoryID
        For Each strChild in objCategories.Item(z).Children
            strHTML = strHTML & VbCrLf & "<br>Child category: " & strChild
        Next
        strHTML = strHTML & VbCrLf & "<br>Category description: " & _
            objCategories.Item(z).Description
        strHTML = strHTML & VbCrLf & "<br>Category order: " & objCategories.Item(z).Order
        strHTML = strHTML & VbCrLf & "<br>Category type: " & objCategories.Item(z).Type
    Next
 
    strHTML = strHTML & VbCrLf & "<br>Deadline: " & colUpdates.Item(i).Deadline
    strHTML = strHTML & VbCrLf & "<br>Delta compressed content available: " & _
        colUpdates.Item(i).DeltaCompressedContentAvailable
    strHTML = strHTML & VbCrLf & "<br>Delta compressed content preferred: " & _
        colUpdates.Item(i).DeltaCompressedContentPreferred
    strHTML = strHTML & VbCrLf & "<br>Description: " & colUpdates.Item(i).Description
    strHTML = strHTML & VbCrLf & "<br>EULA accepted: " & colUpdates.Item(i).EULAAccepted
    strHTML = strHTML & VbCrLf & "<br>EULA text: " & colUpdates.Item(i).EULAText
    strHTML = strHTML & VbCrLf & "<br>Handler ID: " & colUpdates.Item(i).HandlerID
 
    Set objIdentity = colUpdates.Item(i).Identity
    strHTML = strHTML & VbCrLf & "<br>Revision number: " & objIdentity.RevisionNumber
    strHTML = strHTML & VbCrLf & "<br>Update ID: " & objIdentity.UpdateID
 
    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    strHTML = strHTML & VbCrLf & "<br>Can request user input: " & _
        objInstallationBehavior.CanRequestUserInput
    strHTML = strHTML & VbCrLf & "<br>Impact: " & objInstallationBehavior.Impact
    strHTML = strHTML & VbCrLf & "<br>Reboot behavior: " & objInstallationBehavior.RebootBehavior
    strHTML = strHTML & VbCrLf & "<br>Requires network connectivity: " & _
        objInstallationBehavior.RequiresNetworkConnectivity
    strHTML = strHTML & VbCrLf & "<br>Is beta: " & colUpdates.Item(i).IsBeta
    strHTML = strHTML & VbCrLf & "<br>Is hidden: " & colUpdates.Item(i).IsHidden
    strHTML = strHTML & VbCrLf & "<br>Is installed: " & colUpdates.Item(i).IsInstalled
    strHTML = strHTML & VbCrLf & "<br>Is mandatory: " & colUpdates.Item(i).IsMandatory
    strHTML = strHTML & VbCrLf & "<br>Is uninstallable: " & colUpdates.Item(i).IsUninstallable
 
    For Each strLanguage in colUpdates.Item(i).Languages
        strHTML = strHTML & VbCrLf & "<br>Supported language: " & strLanguage
    Next
 
    strHTML = strHTML & VbCrLf & "<br>Last deployment change time: " & _
        colUpdates.Item(i).LastDeploymentChangeTime
    strHTML = strHTML & VbCrLf & "<br>Maximum download size: " & colUpdates.Item(i).MaxDownloadSize
    strHTML = strHTML & VbCrLf & "<br>Minimum download size: " & colUpdates.Item(i).MinDownloadSize
    strHTML = strHTML & VbCrLf & "<br>Microsoft Security Response Center severity: " & _
        colUpdates.Item(i).MsrcSeverity
    strHTML = strHTML & VbCrLf & "<br>Recommended CPU speed: " & _
        colUpdates.Item(i).RecommendedCPUSpeed
    strHTML = strHTML & VbCrLf & "<br>Recommended hard disk space: " & _
        colUpdates.Item(i).RecommendedHardDiskSpace
    strHTML = strHTML & VbCrLf & "<br>Recommended memory: " & colUpdates.Item(i).RecommendedMemory
    strHTML = strHTML & VbCrLf & "<br>Release notes: " & colUpdates.Item(i).ReleaseNotes
    strHTML = strHTML & VbCrLf & "<br>Support URL: " & colUpdates.Item(i).SupportURL
    strHTML = strHTML & VbCrLf & "<br>Type: " & colUpdates.Item(i).Type
    strHTML = strHTML & VbCrLf & "<br>Uninstallation notes: " & _
        colUpdates.Item(i).UninstallationNotes
 
 
    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        strHTML = strHTML & VbCrLf & "<br>KB article: " & strArticle
    Next
 
    strHTML = strHTML & VbCrLf & "<br>Deployment action: " & colUpdates.Item(i).DeploymentAction
Next
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
strHTMLFile = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "Updatecheck.html"
Set objHTMLFile = objFSO.CreateTextFile(strHTMLFile, True)
objHTMLFile.WriteLine "<HTML>"
objHTMLFile.WriteLine "<BODY>"
objHTMLFile.WriteLine strHTML
objHTMLFile.WriteLine "</BODY>"
objHTMLFile.WriteLine "</HTML>"
objHTMLFile.Close
Set objIE = CreateObject("InternetExplorer.Application")
objIE.visible = True
objIE.Navigate2 strHTMLFile
 
Function WMIDateStringToDate(dtmDate)
	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 21818677
Hi, I'm very sorry for my late reply. I've been busy.....and a bit unwell....

Anyway, you did a great job with that script. It worked for me. I have tweaked it slightly...

It's a great script too! I didn't think it was that easy to check for updates!

When you say you get a blank page, check that the file "Updatecheck.html" is being created in the same folder as the VBS file, and right-click it, and open with Notepad, to see if there's any text in it.

Regards,

Rob.
'On Error Resume Next
 
 
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
 
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("Type='Software'")
Set colUpdates = objResults.Updates
 
For i = 0 to colUpdates.Count - 1
    strHTML = strHTML & VbCrLf & "<br>Title: " & colUpdates.Item(i).Title
    strHTML = strHTML & VbCrLf & "<br>Autoselect on Web sites: " & _
        colUpdates.Item(i).AutoSelectOnWebSites
 
    For Each strUpdate in colUpdates.Item(i).BundledUpdates
        strHTML = strHTML & VbCrLf & "<br>Bundled update: " & strUpdate
    Next
    strHTML = strHTML & VbCrLf & "<br>Can require source: " & colUpdates.Item(i).CanRequireSource
    Set objCategories = colUpdates.Item(i).Categories
 
    For z = 0 to objCategories.Count - 1
        strHTML = strHTML & VbCrLf & "<br>Category name: " & objCategories.Item(z).Name
        strHTML = strHTML & VbCrLf & "<br>Category ID: " & objCategories.Item(z).CategoryID
        For Each strChild in objCategories.Item(z).Children
            strHTML = strHTML & VbCrLf & "<br>Child category: " & strChild
        Next
        strHTML = strHTML & VbCrLf & "<br>Category description: " & _
            objCategories.Item(z).Description
        strHTML = strHTML & VbCrLf & "<br>Category order: " & objCategories.Item(z).Order
        strHTML = strHTML & VbCrLf & "<br>Category type: " & objCategories.Item(z).Type
    Next
 
    strHTML = strHTML & VbCrLf & "<br>Deadline: " & colUpdates.Item(i).Deadline
    strHTML = strHTML & VbCrLf & "<br>Delta compressed content available: " & _
        colUpdates.Item(i).DeltaCompressedContentAvailable
    strHTML = strHTML & VbCrLf & "<br>Delta compressed content preferred: " & _
        colUpdates.Item(i).DeltaCompressedContentPreferred
    strHTML = strHTML & VbCrLf & "<br>Description: " & colUpdates.Item(i).Description
    strHTML = strHTML & VbCrLf & "<br>EULA accepted: " & colUpdates.Item(i).EULAAccepted
    strHTML = strHTML & VbCrLf & "<br>EULA text: " & colUpdates.Item(i).EULAText
    strHTML = strHTML & VbCrLf & "<br>Handler ID: " & colUpdates.Item(i).HandlerID
 
    Set objIdentity = colUpdates.Item(i).Identity
    strHTML = strHTML & VbCrLf & "<br>Revision number: " & objIdentity.RevisionNumber
    strHTML = strHTML & VbCrLf & "<br>Update ID: " & objIdentity.UpdateID
 
    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    strHTML = strHTML & VbCrLf & "<br>Can request user input: " & _
        objInstallationBehavior.CanRequestUserInput
    strHTML = strHTML & VbCrLf & "<br>Impact: " & objInstallationBehavior.Impact
    strHTML = strHTML & VbCrLf & "<br>Reboot behavior: " & objInstallationBehavior.RebootBehavior
    strHTML = strHTML & VbCrLf & "<br>Requires network connectivity: " & _
        objInstallationBehavior.RequiresNetworkConnectivity
    strHTML = strHTML & VbCrLf & "<br>Is beta: " & colUpdates.Item(i).IsBeta
    strHTML = strHTML & VbCrLf & "<br>Is hidden: " & colUpdates.Item(i).IsHidden
    strHTML = strHTML & VbCrLf & "<br>Is installed: " & colUpdates.Item(i).IsInstalled
    strHTML = strHTML & VbCrLf & "<br>Is mandatory: " & colUpdates.Item(i).IsMandatory
    strHTML = strHTML & VbCrLf & "<br>Is uninstallable: " & colUpdates.Item(i).IsUninstallable
 
    strLanguages = ""
    For Each strLanguage in colUpdates.Item(i).Languages
        If strLanguages = "" Then
        	strLanguages = strLanguage
        Else
        	strLanguages = strLanguages & ", " & strLanguage
        End If
    Next
    strHTML = strHTML & VbCrLf & "<br>Supported language: " & strLanguages
 
    strHTML = strHTML & VbCrLf & "<br>Last deployment change time: " & _
        colUpdates.Item(i).LastDeploymentChangeTime
    strHTML = strHTML & VbCrLf & "<br>Maximum download size: " & colUpdates.Item(i).MaxDownloadSize
    strHTML = strHTML & VbCrLf & "<br>Minimum download size: " & colUpdates.Item(i).MinDownloadSize
    strHTML = strHTML & VbCrLf & "<br>Microsoft Security Response Center severity: " & _
        colUpdates.Item(i).MsrcSeverity
    strHTML = strHTML & VbCrLf & "<br>Recommended CPU speed: " & _
        colUpdates.Item(i).RecommendedCPUSpeed
    strHTML = strHTML & VbCrLf & "<br>Recommended hard disk space: " & _
        colUpdates.Item(i).RecommendedHardDiskSpace
    strHTML = strHTML & VbCrLf & "<br>Recommended memory: " & colUpdates.Item(i).RecommendedMemory
    strHTML = strHTML & VbCrLf & "<br>Release notes: " & colUpdates.Item(i).ReleaseNotes
    strHTML = strHTML & VbCrLf & "<br>Support URL: " & colUpdates.Item(i).SupportURL
    strHTML = strHTML & VbCrLf & "<br>Type: " & colUpdates.Item(i).Type
    strHTML = strHTML & VbCrLf & "<br>Uninstallation notes: " & _
        colUpdates.Item(i).UninstallationNotes
 
 
    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        strHTML = strHTML & VbCrLf & "<br>KB article: " & strArticle
    Next
 
    strHTML = strHTML & VbCrLf & "<br>Deployment action: " & colUpdates.Item(i).DeploymentAction & "<br><br>"
Next
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
strHTMLFile = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "Updatecheck.html"
Set objHTMLFile = objFSO.CreateTextFile(strHTMLFile, True)
objHTMLFile.WriteLine "<HTML>"
objHTMLFile.WriteLine "<BODY>"
objHTMLFile.WriteLine strHTML
objHTMLFile.WriteLine "</BODY>"
objHTMLFile.WriteLine "</HTML>"
objHTMLFile.Close
Set objIE = CreateObject("InternetExplorer.Application")
objIE.visible = True
objIE.Navigate2 strHTMLFile
 
Function WMIDateStringToDate(dtmDate)
	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Open in new window

0
 

Author Comment

by:Dutchict
ID: 21820196
Hi RobSampson, i get an error on line 101  ; objHTMLFile.WriteLine strHTML
When i integrate this into my other script (so without the html function) my whole scriptoutput turns blanc! Any suggestions?
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 21826676
Hi, I take it you're combining this with the script from here:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23479029.html

I'll have a look at testing it in about an hour or so....

Regards,

Rob.
0
 

Author Comment

by:Dutchict
ID: 21830686
Hi RobSampson, thats correct, the latest build has far more features. It will be a big script to check machines in a heartbeat!
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 21839391
Hi, sorry, I didn't get time to combine these last week.....try this out...I've added some table borders...to make it a bit more readable.

Regards,

Rob.
On Error Resume Next
 
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
 
arrComputers = Array(".")
For Each strComputer In arrComputers
   strHTML = strHTML & VbCrLf & "<br>"
   strHTML = strHTML & VbCrLf & "<br>=========================================="
   strHTML = strHTML & VbCrLf & "<br><b>JMS</b>: " & "Checklist"
   strHTML = strHTML & VbCrLf & "<br>=========================================="
strHTML = strHTML & VbCrLf & "<br><b>Informatie:</b>"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strHTML = strHTML & VbCrLf & "<br><br>Klant: " & objItem.Organization
next
strHTML = strHTML & VbCrLf & "<br><br>Datum: " & (FormatDateTime(Date(),1))
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strHTML = strHTML & VbCrLf & "<br><br>Server: " & objItem.CSName
next
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
 
Set IPConfigSet = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled=TRUE")
 
For Each IPConfig in IPConfigSet
    If Not IsNull(IPConfig.IPAddress) Then 
        For i=LBound(IPConfig.IPAddress) to UBound(IPConfig.IPAddress)
            strHTML = strHTML & VbCrLf & "<br>IP adres: "& IPConfig.IPAddress(i)
        Next
    End If	
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
   For Each objItem In colItems
      strHTML = strHTML & VbCrLf & "<br>OS: " & objItem.Caption
Next
Set oWMI = GetObject("winmgmts://./root/cimv2")
Set cI = oWMI.ExecQuery("Select * from Win32_OperatingSystem", , 48)
For Each oI in cI
	Dim sY, sM, sD, sH, sN, sS, dU, sT, iD, iH, iM, iSS
	'yyyymmddHHMMSS
	sY = Left(oI.LastBootUpTime,4)
	sM = Mid(oI.LastBootUpTime, 5, 2)
	sD = Mid(oI.LastBootUpTime, 7, 2)
	sH = Mid(oI.LastBootUpTime, 9, 2)
	sN = Mid(oI.LastBootUpTime,11, 2)
	sS = Mid(oI.LastBootUpTime,13, 2)
	dU = DateSerial(sY, sM, sD) + TimeSerial(sH, sN, sS)
	iM = DateDiff("n", dU, Now)
	iD = iM \ 1440
	iM = iM - (iD * 1440)
	iH = iM \ 60
	iM = iM - (iH * 60)
Next
strHTML = strHTML & VbCrLf & "<br>Laatste boot: " & iD & " dagen, " & iH & " uren en " & iM & " minuten"
strHTML = strHTML & VbCrLf & "<br><br><b>Schijfbeheer:</b>"
Const HARD_DISK = 3
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = " & HARD_DISK & "")
 
For Each objDisk in colDisks
    strHTML = strHTML & VbCrLf & "<br>Partitie: "& objDisk.DeviceID       
    strHTML = strHTML & VbCrLf & "<br>Vrije disk ruimte: "& objDisk.FreeSpace
Next	
 
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
    ("Select * from Win32_LogicalDisk Where DriveType = 3")
For Each objDisk in colDisks
    intFreeSpace = objDisk.FreeSpace
    intTotalSpace = objDisk.Size
    pctFreeSpace = intFreeSpace / intTotalSpace
    strHTML = strHTML & vbCrLf & objDisk.DeviceID & " " & FormatPercent(pctFreeSpace)
Next
 
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
 
strHTML = strHTML & VbCrLf & "<br><br><b>Processor:</b>"
   For Each objItem In colItems
            strHTML = strHTML & VbCrLf & "<br>Processor: " & objItem.Name
            strHTML = strHTML & VbCrLf & "<br><br>"
   Next
Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PageFileSetting", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
strHTML = strHTML & VbCrLf & "<br><br><b>Pagefile:</b>"
   For Each objItem In colItems
      strHTML = strHTML & VbCrLf & "<br>Grootte: " & objItem.InitialSize
      strHTML = strHTML & VbCrLf & "<br>Maximumgrootte: " & objItem.MaximumSize
      strHTML = strHTML & VbCrLf & "<br>Locatie: " & objItem.Name
      strHTML = strHTML & VbCrLf & "<br><br>"
   Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
strHTML = strHTML & VbCrLf & "<br><br><b>Operating System:</b>"
   For Each objItem In colItems
      strHTML = strHTML & VbCrLf & "<br>Opstartschijf: " & objItem.BootDevice
      strHTML = strHTML & VbCrLf & "<br>Bouwnummer: " & objItem.BuildNumber
      strHTML = strHTML & VbCrLf & "<br>Operating System: " & objItem.Caption
      strHTML = strHTML & VbCrLf & "<br>Service Pack: " & objItem.CSDVersion
      strHTML = strHTML & VbCrLf & "<br>Computernaam: " & objItem.CSName
      strHTML = strHTML & VbCrLf & "<br>Installatie Datum: " & WMIDateStringToDate(objItem.InstallDate)
      strHTML = strHTML & VbCrLf & "<br>Bouwer: " & objItem.Manufacturer
      strHTML = strHTML & VbCrLf & "<br>OS Locatie: " & objItem.Name
      strHTML = strHTML & VbCrLf & "<br>Bedrijf: " & objItem.Organization
      strHTML = strHTML & VbCrLf & "<br>Geregistreerd: " & objItem.RegisteredUser
      strHTML = strHTML & VbCrLf & "<br>Serienummer: " & objItem.SerialNumber
      strHTML = strHTML & VbCrLf & "<br>Versie: " & objItem.Version
      strHTML = strHTML & VbCrLf & "<br>Windows Directory: " & objItem.WindowsDirectory
      strHTML = strHTML & VbCrLf & "<br><br>"
   Next
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_MappedLogicalDisk", "WQL", _
                                          wbemFlagReturnImmediately + wbemFlagForwardOnly)
 
strHTML = strHTML & VbCrLf & "<br><br><b>Mappings:</b> "    
For Each objItem In colItems
       strHTML = strHTML & VbCrLf & "<br>Drive: " & objItem.Caption
      strHTML = strHTML & VbCrLf & "<br>Bestandssysteem: " & objItem.FileSystem
      strHTML = strHTML & VbCrLf & "<br>Vrije ruimte: " & objItem.FreeSpace
      strHTML = strHTML & VbCrLf & "<br>Doel: " & objItem.ProviderName
      strHTML = strHTML & VbCrLf & "<br>Grootte: " & objItem.Size
      strHTML = strHTML & VbCrLf & "<br>Drive naam: " & objItem.VolumeName
      strHTML = strHTML & VbCrLf & "<br><br>"
Next
 
'===============================
 
Set objSearcher = CreateObject("Microsoft.Update.Searcher")
Set objResults = objSearcher.Search("Type='Software'")
Set colUpdates = objResults.Updates
 
strHTML = strHTML & VbCrLf & "<br><br><br>=========================================="
strHTML = strHTML & VbCrLf & "<br><b>Microsoft Updates:</b>"
strHTML = strHTML & VbCrLf & "<br>==========================================<br>"
For i = 0 to colUpdates.Count - 1
    strHTML = strHTML & VbCrLf & "<br><table border=1>"
    strHTML = strHTML & VbCrLf & "<tr><td>Title: </td><td>" & colUpdates.Item(i).Title & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Autoselect on Web sites: </td><td>" & _
        colUpdates.Item(i).AutoSelectOnWebSites & "</td></tr>"
 
    strUpdates = ""
    For Each strUpdate in colUpdates.Item(i).BundledUpdates
    	If strUpdates = "" Then
    		strUpdates = strUpdate
    	Else
    		strUpdates = strUpdates & "," & strUpdate
    	End If
    Next
    strHTML = strHTML & VbCrLf & "<tr><td>Bundled update: </td><td>" & strUpdates & "</td></tr>"
 
    strHTML = strHTML & VbCrLf & "<tr><td>Can require source: </td><td>" & colUpdates.Item(i).CanRequireSource & "</td></tr>"
    Set objCategories = colUpdates.Item(i).Categories
 
    For z = 0 to objCategories.Count - 1
        strHTML = strHTML & VbCrLf & "<tr><td>Category name: </td><td>" & objCategories.Item(z).Name & "</td></tr>"
        strHTML = strHTML & VbCrLf & "<tr><td>Category ID: </td><td>" & objCategories.Item(z).CategoryID & "</td></tr>"
        For Each strChild in objCategories.Item(z).Children
            strHTML = strHTML & VbCrLf & "<tr><td>Child category: </td><td>" & strChild & "</td></tr>"
        Next
        strHTML = strHTML & VbCrLf & "<tr><td>Category description: </td><td>" & _
            objCategories.Item(z).Description & "</td></tr>"
        strHTML = strHTML & VbCrLf & "<tr><td>Category order: </td><td>" & objCategories.Item(z).Order & "</td></tr>"
        strHTML = strHTML & VbCrLf & "<tr><td>Category type: </td><td>" & objCategories.Item(z).Type & "</td></tr>"
    Next
 
    strHTML = strHTML & VbCrLf & "<tr><td>Deadline: </td><td>" & colUpdates.Item(i).Deadline & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Delta compressed content available: </td><td>" & _
        colUpdates.Item(i).DeltaCompressedContentAvailable & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Delta compressed content preferred: </td><td>" & _
        colUpdates.Item(i).DeltaCompressedContentPreferred & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Description: </td><td>" & colUpdates.Item(i).Description & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>EULA accepted: </td><td>" & colUpdates.Item(i).EULAAccepted & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>EULA text: </td><td>" & colUpdates.Item(i).EULAText & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Handler ID: </td><td>" & colUpdates.Item(i).HandlerID & "</td></tr>"
 
    Set objIdentity = colUpdates.Item(i).Identity
    strHTML = strHTML & VbCrLf & "<tr><td>Revision number: </td><td>" & objIdentity.RevisionNumber & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Update ID: </td><td>" & objIdentity.UpdateID & "</td></tr>"
 
    Set objInstallationBehavior = colUpdates.Item(i).InstallationBehavior
    strHTML = strHTML & VbCrLf & "<tr><td>Can request user input: </td><td>" & _
        objInstallationBehavior.CanRequestUserInput & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Impact: </td><td>" & objInstallationBehavior.Impact & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Reboot behavior: </td><td>" & objInstallationBehavior.RebootBehavior & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Requires network connectivity: </td><td>" & _
        objInstallationBehavior.RequiresNetworkConnectivity & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Is beta: </td><td>" & colUpdates.Item(i).IsBeta & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Is hidden: </td><td>" & colUpdates.Item(i).IsHidden & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Is installed: </td><td>" & colUpdates.Item(i).IsInstalled & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Is mandatory: </td><td>" & colUpdates.Item(i).IsMandatory & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Is uninstallable: </td><td>" & colUpdates.Item(i).IsUninstallable & "</td></tr>"
 
    strLanguages = ""
    For Each strLanguage in colUpdates.Item(i).Languages
        If strLanguages = "" Then
        	strLanguages = strLanguage
        Else
        	strLanguages = strLanguages & ", " & strLanguage
        End If
    Next
    strHTML = strHTML & VbCrLf & "<tr><td>Supported language: </td><td>" & strLanguages & "</td></tr>"
 
    strHTML = strHTML & VbCrLf & "<tr><td>Last deployment change time: </td><td>" & _
        colUpdates.Item(i).LastDeploymentChangeTime & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Maximum download size: </td><td>" & colUpdates.Item(i).MaxDownloadSize & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Minimum download size: </td><td>" & colUpdates.Item(i).MinDownloadSize & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Microsoft Security Response Center severity: </td><td>" & _
        colUpdates.Item(i).MsrcSeverity & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Recommended CPU speed: </td><td>" & _
        colUpdates.Item(i).RecommendedCPUSpeed & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Recommended hard disk space: </td><td>" & _
        colUpdates.Item(i).RecommendedHardDiskSpace & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Recommended memory: </td><td>" & colUpdates.Item(i).RecommendedMemory & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Release notes: </td><td>" & colUpdates.Item(i).ReleaseNotes & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Support URL: </td><td>" & colUpdates.Item(i).SupportURL & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Type: </td><td>" & colUpdates.Item(i).Type & "</td></tr>"
    strHTML = strHTML & VbCrLf & "<tr><td>Uninstallation notes: </td><td>" & _
        colUpdates.Item(i).UninstallationNotes & "</td></tr>"
 
 
    For Each strArticle in colUpdates.Item(i).KBArticleIDs
        strHTML = strHTML & VbCrLf & "<tr><td>KB article: </td><td>" & strArticle & "</td></tr>"
    Next
 
    strHTML = strHTML & VbCrLf & "<tr><td>Deployment action: </td><td>" & colUpdates.Item(i).DeploymentAction & "<td><tr>"
    strHTML = strHTML & VbCrLf & "</table><br><br>"
Next
'===============================
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
strHTMLFile = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "HTMLPage.html"
Set objHTMLFile = objFSO.CreateTextFile(strHTMLFile, True)
objHTMLFile.WriteLine "<HTML>"
objHTMLFile.WriteLine "<BODY>"
objHTMLFile.WriteLine strHTML
objHTMLFile.WriteLine "</BODY>"
objHTMLFile.WriteLine "</HTML>"
objHTMLFile.Close
Set objIE = CreateObject("InternetExplorer.Application")
objIE.visible = True
objIE.Navigate2 strHTMLFile
 
Function WMIDateStringToDate(dtmDate)
	WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
	Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
	& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Open in new window

0
 

Author Closing Comment

by:Dutchict
ID: 31466871
Sorry for late reaction, it does work on several workstation, but on some others it doens't.. anyway, your time, your points ;)
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 21921659
Thanks for the grade.

On those machines that it doesn't work, you may find that it works if your log on as an Administrator.

Two reasons I can think of why it might not work...
1) The user who has logged on does not have rights to read those Win32 classes
2) The user may have proxy restricitions for the microsoft update website

Regards,

Rob.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question