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!
Share
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:
Have a look at the
windows-updatetag 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.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.
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.