[研究]Windows Update Agent (WUA)離線檢查Windows安全性
2023-05-04
使用 WUA 掃描離線更新 - Win32 apps | Microsoft Learn
https://learn.microsoft.com/zh-tw/windows/win32/wua_sdk/using-wua-to-scan-for-updates-offline
Windows Update Agent (WUA) 可用來掃描電腦是否有安全性更新,而不需要連線到Windows Update或Windows Server Update Services (WSUS) 伺服器,這可讓未連線到網際網路的電腦掃描安全性更新。
離線掃描更新需要從Windows Update下載已簽署的檔案Wsusscn2.cab。
wscript | Microsoft Learn
VBScript Code (w.vbs)
Set UpdateSession = CreateObject("Microsoft.Update.Session")
Set UpdateServiceManager = CreateObject("Microsoft.Update.ServiceManager")
Set UpdateService = UpdateServiceManager.AddScanPackageService("Offline Sync Service", "c:\TempC\wsusscn2.cab")
Set UpdateSearcher = UpdateSession.CreateUpdateSearcher()
WScript.Echo "Searching for updates..." & vbCRLF
UpdateSearcher.ServerSelection = 3 ' ssOthers
UpdateSearcher.ServiceID = UpdateService.ServiceID
Set SearchResult = UpdateSearcher.Search("IsInstalled=0")
Set Updates = SearchResult.Updates
If searchResult.Updates.Count = 0 Then
WScript.Echo "There are no applicable updates."
WScript.Quit
End If
WScript.Echo "List of applicable items on the machine when using wssuscan.cab:" & vbCRLF
For I = 0 to searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
WScript.Echo I + 1 & "> " & update.Title
Next
WScript.Quit
|
敝人把 wsusscn2.cab 和 w.vbs 都放 C:\TempC 目錄,所以相關路徑也要修改。
執行結果
********************************************************************************
如果是有尚未完成 Windows Update 的 Windows,訊息會顯示那些待更新
(完)
沒有留言:
張貼留言