C#/WMI:如何远程检查 Windows 是否已准备好安装更新?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3615895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C#/WMI: How to remotely check if Windows has updates ready to be installed?
提问by Daniel
I tried finding a solution for this on google without much luck, perhaps someone here knows how to do this?
我尝试在谷歌上找到解决方案,但运气不佳,也许这里有人知道如何做到这一点?
采纳答案by Hans Olsson
Not sure if you can do it remotely as such, but you could "fake" it.
不确定您是否可以像这样远程执行此操作,但是您可以“伪造”它。
Look at the MSDN documentation for the Windows Update Agent API, specifically the article called Searching, Downloading, and Installing Updates. That contains a script that among other things lists the updates ready to be installed. If you take that bit of the script and amend it to instead write a list to a file, then you could copy the script over to a remote computer, execute the script remotely, then read the file (and finally delete the file and the script from the remote computer to clean up).
查看Windows Update Agent API的 MSDN 文档,特别是名为Searching, Downloading, and Installing Updates 的文章。其中包含一个脚本,其中列出了准备安装的更新。如果您使用脚本的那一点并将其修改为将列表写入文件,那么您可以将脚本复制到远程计算机,远程执行脚本,然后读取文件(最后删除文件和脚本从远程计算机清理)。
You can execute a script remotely using WMI, see this CodeProject article for details for doing so from C#: Create a Remote Process using WMI in C#
您可以使用 WMI 远程执行脚本,有关从 C# 执行此操作的详细信息,请参阅此 CodeProject 文章:在 C# 中使用 WMI 创建远程进程