我想在離線獨立 Win7 Kiosk 機器上運行的 WinForm 中檢查特定的 Windows 安全更新。我想我有一個無限回圈,因為當我運行這段代碼時它只是掛起。我似乎找不到我的問題。我在 C# 中找到了類似的代碼,并嘗試將其轉換為 VB.NET,但也許我沒有正確執行。
我基本上只是想檢查系統的 KB3033929,然后如果它已安裝,隱藏一個按鈕并顯示一個標簽。
' ***** CHECK FOR PATCH *****
Dim objSession = CreateObject("Microsoft.Update.Session")
Dim objSearcher = objSession.CreateUpdateSearcher
Dim objResults = objSearcher.Search("Type='Software'")
Dim colUpdates = objResults.Updates
For i = 0 To colUpdates.Count - 1
If colUpdates.Item(i).Title = "Security Update for Windows (KB3033929)" Then
If colUpdates.Item(i).IsInstalled <> 0 Then
Label4.Visible = True
PatchInstall.Visible = False
End If
End If
Next
uj5u.com熱心網友回復:
如果我錯了,請糾正我,但經過更多研究,我認為這符合我的需要?老實說,我仍在嘗試理解它,但是在安裝補丁后,我從 MsgBox 中獲得了帶有以下代碼的彈出視窗:
'***** CHECK FOR PATCH *****
Private Sub CheckPatch()
Dim ConOptions As New ConnectionOptions() With {.EnablePrivileges = True, .Timeout = EnumerationOptions.InfiniteTimeout}
Dim mOptions As New EnumerationOptions() With {.Rewindable = False, .ReturnImmediately = True, .DirectRead = True, .EnumerateDeep = False}
Dim mQuery As New SelectQuery("SELECT HotFixID FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB3033929'")
Dim mScope As New ManagementScope($"\\{Environment.MachineName}\root\CIMV2", ConOptions)
mScope.Connect()
Using moSearcher As New ManagementObjectSearcher(mScope, mQuery, mOptions)
If moSearcher.Get().Count > 0 Then
MsgBox("Patch Installed!")
End If
End Using
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/490844.html
