WMI 查询系统中安装的修补程序列表? [英] WMI Query for list of hotfixes installed in a system?

查看:39
本文介绍了WMI 查询系统中安装的修补程序列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 perl 脚本,它会列出我系统中安装的修补程序,并在开始我的程序之前检查是否有任何先决条件的修补程序不可用;

所以我需要能够枚举系统中的修补程序列表;这里 提到了使用 wmic 生成 html 文件.是否可以通过 WMI 查询执行此操作?

解决方案

我自己已经找到了答案!!此处提供了一个 vbscript 选项.>

perl 版本是这样的..

use Win32::OLE qw( in );我的 $machine = ".";my $WMIServices = Win32::OLE->GetObject ( "winmgmts:{impersonationLevel=impersonate,(security)}//$machine/root/cimv2") ||死不能调用getobject";我的 $HotFixCollection = $WMIServices->ExecQuery ( "select * from Win32_QuickFixEngineering" ) ||die "查询失败";foreach 我的 $hotfix ( in( $HotFixCollection )){$hotfixID = $hotfix->{HotFixID};打印 "修补程序 ID 是 $hotfixID \n";}

I am writing a perl script that will list the hotfixes installed in my system and check if any pre-requisite hotfixes are not available before beginning my program;

So I need to be able to enumerate the list of hotfixes in the system; Here there is a mention of using wmic to generate a html file. Is it possible to do this via a WMI query?

解决方案

I have figured out the answer for this myself!! There is a vbscript option provided here.

The perl version goes like this..

use Win32::OLE qw( in );
my $machine = ".";
my $WMIServices = Win32::OLE->GetObject ( "winmgmts:{impersonationLevel=impersonate,(security)}//$machine/root/cimv2" ) || die "cant call getobject";
my $HotFixCollection = $WMIServices->ExecQuery ( "select * from Win32_QuickFixEngineering" ) || die "Query Failed";

foreach my $hotfix ( in( $HotFixCollection )){
 $hotfixID = $hotfix->{HotFixID};
 print "Hotfix id is $hotfixID \n";
}

这篇关于WMI 查询系统中安装的修补程序列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆