Windows 脚本宿主和快速修复工程

发布于 2024-09-28 12:07:36 字数 1039 浏览 3 评论 0原文

我想获取已安装的 Windows 修补程序和更新的列表。我使用下面的脚本:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuickFixes = objWMIService.ExecQuery _
("Select * from Win32_QuickFixEngineering")

Set objDateTime = CreateObject("WbemScripting.SWbemDateTime")

For Each objQuickFix in colQuickFixes
Wscript.Echo "Computer: " & objQuickFix.CSName
Wscript.Echo "Description: " & objQuickFix.Description
Wscript.Echo "Hot Fix ID: " & objQuickFix.HotFixID
If Not (IsNull(objQuickFix.InstallDate) Or _
IsEmpty(objQuickFix.InstallDate)) Then
objDateTime.Value = objQuickFix.InstallDate
Wscript.Echo "Installation Date: " & objDateTime.GetFileTime
Else
WScript.Echo "Install Date Type: " &
TypeName(objQuickFix.InstallDate)
End If
Wscript.Echo "Installed By: " & objQuickFix.InstalledBy
Next

当我运行此脚本时,我收到错误消息:

Syntax error
Error Code 800A03EA

这段代码有什么问题?谢谢! 抱歉,如果我的英语不完美。

I want to get list of installed windows hotfix and updates. I use script below:

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colQuickFixes = objWMIService.ExecQuery _
("Select * from Win32_QuickFixEngineering")

Set objDateTime = CreateObject("WbemScripting.SWbemDateTime")

For Each objQuickFix in colQuickFixes
Wscript.Echo "Computer: " & objQuickFix.CSName
Wscript.Echo "Description: " & objQuickFix.Description
Wscript.Echo "Hot Fix ID: " & objQuickFix.HotFixID
If Not (IsNull(objQuickFix.InstallDate) Or _
IsEmpty(objQuickFix.InstallDate)) Then
objDateTime.Value = objQuickFix.InstallDate
Wscript.Echo "Installation Date: " & objDateTime.GetFileTime
Else
WScript.Echo "Install Date Type: " &
TypeName(objQuickFix.InstallDate)
End If
Wscript.Echo "Installed By: " & objQuickFix.InstalledBy
Next

When I run this script I get Error message:

Syntax error
Error Code 800A03EA

What's wrong in this piece of code? Thanks!
Sorry if my English is not perfect.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紅太極 2024-10-05 12:07:36

您在这里缺少行继续符 (_):

''#                        -----------
''#                                  |
''#                                  \/

WScript.Echo "Install Date Type: " & _
TypeName(objQuickFix.InstallDate)

添加它或将代码放在单行中:

WScript.Echo "Install Date Type: " & TypeName(objQuickFix.InstallDate)

You are missing the line continuation character (_) here:

''#                        -----------
''#                                  |
''#                                  \/

WScript.Echo "Install Date Type: " & _
TypeName(objQuickFix.InstallDate)

Either add it or put the code in a singe line:

WScript.Echo "Install Date Type: " & TypeName(objQuickFix.InstallDate)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文