WMI获得认证机构列表

时间:2018-02-02 08:54:51

标签: windows batch-file cmd wmi wmic

我尝试编写2个 WMIC 命令,用于生成mashine上所有已安装应用程序的列表,另一个证书,并将其写入文件。

问题是我的证书命令无法正常运行。第二个命令返回与安装的aplications相同的文件,除了安装的证书。我真的不明白为什么,因为在我看来,命令看起来不错。这是以下两个命令:

rem command to check installed aplications
wmic product get /format:csv > %USERPROFILE%/Desktop/vistadraft-applications-%Computername%-%Username%.csv && echo [.] [STARTING] && echo [.] application version list [PROCESSING] && echo [.] [FINISHED]

rem command to check installed certificates
wmic product get /format:csv > %USERPROFILE%/Desktop/vistadraft-certificates-%Computername%-%Username%.csv && echo [.] [STARTING] && echo [.] certification authorities list [PROCESSING] && echo [.] [FINISHED]

拜托,也许是谁知道哪里有问题?

1 个答案:

答案 0 :(得分:0)

引用msdn

  

要运行以下WMI命令行工具,您的帐户必须位于Administrators组中,并且必须从提升的命令提示符运行该工具。内置管理员帐户也可以运行这些工具。

因此,您需要以管理员身份运行wmic。

a。只需右键点击cmd.exe并选择"Run as Administrator",然后从那里运行您的脚本。

b。保存批处理文件并右键单击,选择Run as Administrator

最后,我建议你用双引号包装你的路径。

rem command to check installed aplications
wmic product get /format:csv > "%USERPROFILE%/Desktop/vistadraft-applications-%Computername%-%Username%.csv" && echo [.] [STARTING] && echo [.] application version list [PROCESSING] && echo [.] [FINISHED]

rem command to check installed certificates
wmic product get /format:csv > "%USERPROFILE%/Desktop/vistadraft-certificates-%Computername%-%Username%.csv" && echo [.] [STARTING] && echo [.] certification authorities list [PROCESSING] && echo [.] [FINISHED]