Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C#/WMI: How to remotely check if Windows has updates ready to be installed?

I tried finding a solution for this on google without much luck, perhaps someone here knows how to do this?

like image 740
Daniel Avatar asked Nov 06 '22 09:11

Daniel


1 Answers

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).

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#

like image 111
Hans Olsson Avatar answered Nov 09 '22 07:11

Hans Olsson