CLI way of uninstalling a Windows update?

10,342

Solution 1

For Server 2003 and XP you could try:

C:\WINDOWS\$NtUninstallKB940157$\spuninst\spuninst.exe /quiet /norestart

Where the KB number would be the KB you would like to kill.

Solution 2

You can use use wusa /uninstall /kb:{updateid}

http://www.sevenforums.com/tutorials/109213-windows-update-uninstall-console-level.html

Share:
10,342

Related videos on Youtube

Miguel Moll
Author by

Miguel Moll

Updated on September 18, 2022

Comments

  • Miguel Moll
    Miguel Moll over 1 year

    Basically, what can be achieved by going to Control Panel > Uninstall a Program > View Installed Updates > Right Click Uninstall, but through the command line? Looking for a way that works across the Windows platform but if (and according to my reading, most likely) it's version dependent so be it.

    Maybe something like:

    C:\command /uninstall "Security Update for Windows 7 for x64-based Systems (KB2705219)"

    Looks like using the KB would be great but wusa.exe works for the above example update but not for say "Security Update for Silverlight (KBXXXXXXXX)". Not much consistency.

    I'm really surprised there isn't much documentation on this. How does an app like WUInstall do it?

    Follow up question is how is that list of "View Installed Updates" populated? I've searched the registry like crazy hoping for an "UninstallString" or equivalent but only found references to the regular Add/Remove Programs list.

    • Admin
      Admin over 11 years
      Related: superuser.com/questions/270610/…. Not a direct duplicate, but one of the answers there applies.
    • Admin
      Admin over 11 years
      @Indrek thanks for the comment! Rolling back to a previous restore point is one way to handle it and I got that done, no problem. But it would be a pain to undo x amount of updates when only one of them needs to be removed. And as stated in the question, I'd really love to know how WUInstall does it.
    • Admin
      Admin over 11 years
      This answer uses wuinstall to remove an update with a known KB number: superuser.com/a/469511
    • Admin
      Admin over 11 years
      Hey @ThiagoM! I know wuinstall can do it. But I was hoping to not depend on a third-party app. I imagine wuinstall is using something provided by the OS, no?
    • Admin
      Admin over 11 years
      Windows updates can be uninstalled and enumerated with wusa, sounds like you already know about that. Application updates based on Windows Installer can be uninstalled with msiexec, but I don't know of any built-in command-line tool to enumerate them. I also don't know if there are any additional types of updates shown on the Installed Updates list.
    • Admin
      Admin over 11 years
      There is Far Manager and my plugin Uninstall which allows to enumerate, filter, examine and uninstall programs. It also reveals uninstall command.
    • Admin
      Admin over 11 years
      @radioact1ve wusa /uninstall /kb:{update ID} ... or did i miss something?....sevenforums.com/tutorials/…
    • Admin
      Admin over 11 years
      @Moab You are right on! At least what I've read about wusa is that its Win7(Vista?) only. Hoping for an XP - 7 compatible way. I can dream...
    • Admin
      Admin over 11 years
      @radioact1ve not possible, windows update changed dramatically starting with Vista. XP can be done from the command line but uses a completely different command sequence.
    • Admin
      Admin over 11 years
      @Moab Fair enough. That's what I thought. Looks like wusa for some updates and msiexec for the others.
    • Admin
      Admin over 10 years
      The Stack Overflow link is broken - the question has been deleted now.
  • Miguel Moll
    Miguel Moll over 11 years
    Yes this is what I've been using. Works great.
  • Peter Mortensen
    Peter Mortensen over 10 years
    What are the prerequisites for wusa? For instance, what versions of Windows?
  • a13ph
    a13ph almost 10 years
    @PeterMortensen - from XP 32bit up, according to whatisdll.com/wusa-exe-repair-free-download-windows-78xpvist‌​a and at least from Vista up according to support.microsoft.com/kb/934307 but that is probably because Microsoft stopped XP support