Run specific script after every Windows Update

Solution 1:

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.

Event Viewer WindowsUpdateClient Event ID 19

Launch the Task Scheduler snap-in, taskschd.msc. Right click the "Task Scheduler Library" and select "Create Basic Task...".

Create Basic Task

In the next screen, input a name and a brief description and click "Next".

Generic name and description

Click the radio button labeled "When a specific event is logged", click "Next".

When a specific event is logged

Select "System" as the log, "WindowsUpdateClient" as the source and "19" as Event ID, click "Next".

Log source and event ID

Click the "Start a program" radio button, click "Next".

Start a program

Provide the path to your "fix it" script or executable, click "Next".

path to script

Review your settings are correct, then click "Finish".

enter image description here

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.

REM Create scheduled task triggered by WindowsUpdateClient event ID 19
schtasks /Create /TN "Post WUA Update Install" /TR "C:\scripts\your.fix.cmd" /SC ONEVENT /EC System /MO "*[System[Provider[@Name='Microsoft-Windows-WindowsUpdateClient'] and (EventID=19)]]"