VBScriptでWindows Update
ここではVBScriptを使用してWindows Updateを実行する方法を解説します。
VBScriptからWindows Updateを実行するにはWindows Update Agent(WUA) APIを使用します。
WUA APIをWindows Updateのダウンロードおよびインストールを行うことが出来ます。
以下はWindows Updateのダウンロードからインストールまでの例です。
Set session = CreateObject("Microsoft.Update.Session") ' Windows Updateを検索 Set searcher = updateSession.CreateupdateSearcher() Set result = searcher.Search("IsInstalled=0 and Type='Software' and AutoSelectOnWebSites=1") ' Windows Updateをダウンロード Set downloader = session.CreateUpdateDownloader() downloader.Updates = result.Updates downloader.Download() ' Windows Updateをインストール Set installer = session.CreateUpdateInstaller() installer.Updates = result.Updates Set installationResult = installer.Install()