[英]Get all updates from a Windows computer with programming
我正在尋找一種從工作站或服務器 (Microsoft Windows) 獲取所有更新的方法。
當我查看控制面板 → 程序 → 程序和功能 → 已安裝的更新時,我還可以看到 Visual Studio 和其他產品的更新。
例子:
Visual Studio 2015 Update 3 (KB3022398) Update for Microsoft Visual Studio 2015 (KB3165756)
但是我嘗試過的所有編程方式都沒有讓我獲得 Visual Studio 的更新。 我怎樣才能做到這一點?
我試過了:
$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$HistoryCount = $Searcher.GetTotalHistoryCount()
$Updates = $Searcher.QueryHistory(0,$HistoryCount)
$Updates | Select Title, @{l='Name';e={$($_.Categories).Name}}, Date | ft
Get-HotFix
Get-WmiObject -Class "Win32_QuickfixEngineering"
任何有關如何以編程方式獲取所有更新的幫助將不勝感激。
如果您使用的是 C#,則可以使用WUApiLib
Type t = Type.GetTypeFromProgID("Microsoft.Update.Session",
UpdateSession UpdateSession = (UpdateSession)Activator.CreateInstance(
IUpdateSearcher UpdateSearchResult = UpdateSession.CreateUpdateSearcher();
UpdateSearchResult.Online = true;
ISearchResult SearchResults = UpdateSearchResult.Search("IsInstalled=1 AND IsPresent=1");
第二個選項是從下面提到的注冊表項中讀取信息
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.