Is there a way to run a specific script each time Windows update completes (i.e., after reboot or after an update that doesn't require a reboot)?
My application is suffering from MSCOMCTL.OCX updates, and it seems that every time Windows Update updates, the user is required to apply my fixup script.
EDIT: For Windows 7 and later.
I believe, ultimately, the correct answer is "Fix your application". However, you may not be able to for any number of reasons. That being said...
Which version of Windows? In Vista/2008 and up, you can tie Scheduled Tasks to specific Event IDs. In the System event log, Event ID 19 from WindowsUpdateClient, indicates successful WUA Update Installation.
Launch the Task Scheduler snap-in,
taskschd.msc
. Right click the "Task Scheduler Library" and select "Create Basic Task...".In the next screen, input a name and a brief description and click "Next".
Click the radio button labeled "When a specific event is logged", click "Next".
Select "System" as the log, "WindowsUpdateClient" as the source and "19" as Event ID, click "Next".
Click the "Start a program" radio button, click "Next".
Provide the path to your "fix it" script or executable, click "Next".
Review your settings are correct, then click "Finish".
You will now see the Scheduled Task listed in the library with your settings.
Here is a command line example using only
C:\Windows\system32\schtasks.exe
, the XPath filter syntax took me a while. It appears the Task Scheduler uses only a subset of XPath.