question

TakuyaYokoi-5315 avatar image
0 Votes"
TakuyaYokoi-5315 asked TakuyaYokoi-5315 commented

WUA API(wuapi.h)のIUpdateInstaller4::Commitが使えない

〇Please describe the issue in 2-3 sentences. Include what you're trying to accomplish when the issue occurs.
WUA APIを用いて、Windows Updateを自動化しようとしていた。

94628-20210507-wua-version.png94648-20210507-os-version.png〇When did it begin and how often does it occur?
Microsoftのサイト(https://docs.microsoft.com/en-us/windows/win32/wua_sdk/searching--downloading--and-installing-updates)から引用したスクリプトを用いてWindows Updateの自動化を検証していたところ

〇What errors do you see?
UpdateInstallerオブジェクトでサポートされてないメソッドを呼び出しているようでした。
エラーメッセージ:Microsoft VBScript 実行時エラー: オブジェクトでサポートされていないプロパティまたはメソッドで す。: 'Commit'

〇What's the environment and are there recent changes?
WUAのバージョンとOSのバージョンについて添付します。

〇What have you tried to troubleshoot this?
UpdateInstallerにあるメソッドをほかにも呼び出してみたところ、いくつか呼び出せないものがあるようでした。
Microsoft VBScript 実行時エラー: オブジェクトでサポートされていないプロパティまたはメソッドです。: 'get_AttemptCloseAppsIfNecessary'
Microsoft VBScript 実行時エラー: オブジェクトでサポートされていないプロパティまたはメソッドです。: 'get_ClientApplicationID'
Microsoft VBScript 実行時エラー: オブジェクトでサポートされていないプロパティまたはメソッドです。: 'get_IsBusy'

一旦、上記サイト((https://docs.microsoft.com/en-us/windows/win32/wua_sdk/searching--downloading--and-installing-updates))記載のスクリプトを動かすためには、WUAのバージョンとOSのバージョンを上げる必要があるかと思いますが、最新バージョンまで上げれば上記事象は解決しますでしょうか
とりあえず、IUpdateInstaller4::Commitのmethod(https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nf-wuapi-iupdateinstaller4-commit)を使えれば、スクリプトは使えるのでしょうか


windows-api
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,
According to your description, the issue is related to windows api, so I'll remove the irrelevant tag about windows server 2016 and add the tag "windows-api-general" instead.
Thank you for your understanding.

0 Votes 0 ·

Hi, Feng

Thanks for re-tagging! Sorry for the mistake in the tag.
I hope this problem will be solved soon.

0 Votes 0 ·

Hi, I'm sorry I can't reproduce the problem with your description of the construction project. Could you please show a minimal, reproducible sample without private information?

0 Votes 0 ·

Hi, Thank you for your efforts in resolving this issue.
From the server in question, I will send you the actual wuapi caller's C:\Windows System32\wuapi.dll file and the script used for verification.
You can download it from the following DL site.

URL : https://upload.hdedrive.com/ui/usen-next.jp/dl/SB1620709443-814585ff-f77f-4bbc-9344-47364ca2e9cf
password : vG^y5AcEerLi
expire date : 2021/05/25 14:04:03

0 Votes 0 ·

1 Answer

SongZhu-MSFT avatar image
0 Votes"
SongZhu-MSFT answered TakuyaYokoi-5315 commented

After my investigation, two problems appeared in your code.

The first problem is that Set should not be used to set the value of isBusy and ClientApplicationID, the reason is: When you assign an object to a variable, you only need to use `Set`, and something like IsBusy just returns the variable.


Then, I checked the methods and members supported by UpdateInstaller through PowShell:

95524-image.png

You can find all the methods and members it supports, including IsBusy and ClientApplicationID, but not AttemptCloseAppsIfNecessary and Commit.

So you can modify the code to:

 Option Explicit
    
 WScript.Echo "This script shows WUA version"
    
 ' Supported parameters:
 '    /AppName: Name to pass to the WUA API as the 'calling application';
 '             this appears in the Windows Update logs
 '             Default: "WUA API Sample Script"
    
 Dim appName
 If WScript.Arguments.Named.Exists("AppName") Then
     appName = WScript.Arguments.Named.Item("AppName")
 Else
     appName = "WUA Script for show version"
 End If
    
 Dim returnValue
 returnValue = 0
    
 Dim updateSession
 Set updateSession = CreateObject("Microsoft.Update.Session")
 updateSession.ClientApplicationID = appName
    
 Dim agentInfo
 Set agentInfo = CreateObject("Microsoft.Update.AgentInfo")
 Dim version1
 version1 = agentInfo.GetInfo("ApiMajorVersion")
 Dim version2
 version2 = agentInfo.GetInfo("ApiMinorVersion")
 Dim version3
 version3 = agentInfo.GetInfo("ProductVersionString")
    
 WScript.Echo version1
 WScript.Echo version2
 WScript.Echo version3
    
 Dim installer
 Set installer = updateSession.CreateUpdateInstaller()
 Dim isBusy
 Dim AttemptCloseAppsIfNecessary
 Dim ClientApplicationID
 Dim Commit
    
    
 isBusy = installer.IsBusy
 WScript.Echo isBusy
    
 ClientApplicationID = installer.ClientApplicationID
 WScript.Echo ClientApplicationID
    
 WScript.Quit (returnValue)


And it works for me.


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



[4]: https://docs.microsoft.com/en-us/answers/articles/67444/email-notifications.html


image.png (36.5 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for your investigation!

I missed the UpdateInstaller3 page(https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdateinstaller3).

I have confirmed that the Commit and AtemptCloseAppsIfNecessary methods are not supported for the UpdateInstaller object on the my server.

I appreciate your kind attention to this issue.






0 Votes 0 ·