从Python下载/安装Windows更新 [英] Download / Install Windows Updates from Python

查看:135
本文介绍了从Python下载/安装Windows更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用脚本来自动安装Windows Updates,我可以在几台机器上部署,所以我不用担心手动更新它们。我想在Python中写这个,但是找不到有关如何做的事情。我需要知道如何搜索更新,下载更新并从python脚本安装它们。任何帮助都会很棒!

I am working on a script to automate the installation of Windows Updates, that I can deploy on several machines so I do not have to worry about updating them manually. I would like to write this in Python, but could not find anythng on how this would be done. I need to know how to search for updates, download the updates and install them all from a python script. Any help would be great!

推荐答案

让我从这开始:我不认为Python脚本是最好的工具工作。如果您想要进行企业级更新管理(例如,对于网络上的所有计算机),那么您应该认真考虑使用现有的MS工具

Let me start with this: I don't think a Python script is the best tool for the job. If you want to do enterprise-level management of updates (e.g., for all machines on a network), then you should seriously consider using the existing MS tools.

就是这样,你可以这么说:

With that said, here is how you might go about this:


  1. 看看ServerFault上的 windows-update 标签,StackOverflow的姊妹站点之一: https://serverfault.com/questions/tagged/windows-update 。很多问题似乎涵盖了更新过程的命令行控制。请记住,命令行工具之间的差异很大。一方面是Windows XP,另一方面则是Vista / 7。有一些运气,你应该能够使用Windows内置命令,而不是以编程方式访问Windows更新网站。
  1. Have a look at the windows-update tag on ServerFault, one of StackOverflow's sister sites: https://serverfault.com/questions/tagged/windows-update . A lot of the questions seem to cover command-line control of the update process. Keep in mind that the command line tools vary significantly between e.g. Windows XP on the one hand and Vista/7 on the other. With some luck, you should be able to use windows built-in commands rather than going to the windows update website programmatically.

假设你找到了命令行您需要的咒语:使用子过程模块调用shell并执行这些命令编程。因为你使用python,你可能需要花费相当多的时间来分析命令输出来弄清楚你的shell调用是如何做的。

Assuming you find the command-line incantations that you need: Use the subprocess module to call to the shell and execute those commands programmatically. Because you're using python, you may need to spend quite a bit of time parsing the command outputs to figure out how your shell calls are doing.

希望有所帮助。我意识到这是一个相当高层次的答案,但是就目前而言,问题不在于您想要完成什么,以及为什么要使用python来完成此任务。

Hope that helps. I realize this is a rather high-level answer, but as it stands, the question is not very specific about what exactly you want to accomplish and why you're using python to do it.

这篇关于从Python下载/安装Windows更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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