我正在编写一个 perl 脚本,它将列出我系统中安装的修补程序,并在开始我的程序之前检查是否有任何必备的修补程序可用;
所以我需要能够枚举系统中的修补程序列表;这里提到了使用 wmic 生成 html 文件。是否可以通过 WMI 查询来做到这一点?
我自己已经找到了答案!!这里提供了一个 vbscript 选项。
perl 版本是这样的..
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";
}