Enabling and Disabling Microsoft Update in Windows 7 via Script


The Windows Update Feature in Windows 7 allows administrators to configure it to either service Windows only or to extend it to other products from Microsoft Update. In most cases, Windows Update is used by end-users only with no need to automate or script this process, since larger organisations usually utilise other means like System Center Configuration Manager to keep their systems up to date.

image

In some cases, however, you actually do get into the position where you want (or need) to change this setting for your end users, so scripting it can come in handy.

How to do this is documented here: http://msdn.microsoft.com/en-us/library/aa826676(VS.85).aspx and can be achieved via a simple script:

Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager")
ServiceManager.ClientApplicationID = "My App"
‘add the Microsoft Update Service by GUID
Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")

The reverse step is also possible with a simple alteration:

Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager")
ServiceManager.ClientApplicationID = "My App"
‘remove the Microsoft Update Service by GUID
ServiceManager.RemoveService("7971f918-a847-4430-9279-4a52d1efe18d")


Comments (19)

  1. Ove Starckjohann says:

    any chance to let this script do it's work via GPO to automatically deploy the change from Windows Update to Microsoft Update ?

    On my side it only succeeded when running it manually as administrator but not when running via gpo-login-skript :-(

    Ove

  2. David Guyer says:

    This helped me fix my machine which I had updated from Win7 to Win8 and was unable to get WU to work.  Thank you.

  3. NB1 says:

    Worked perfectly

  4. Internet Exploder says:

    This is an excellent script for those of us who got rid of Internet Explorer (a major security hole in the default install), but can no longer change the "Get updates for other Microsoft products" – the link is not doing anything since it relies on iexplorer.exe
    and even if you visit the link it will only allow you to change the setting in Internet Explorer not any other broweser like Chrome or Firefox.

    Just in case it’s not clear for regular users: open Notepad, save the contents of the first script as "script.vbs" (without any extra .txt extension !), open a command prompt as Administrator, change directory to where you saved the script, and run it by typing
    script.vbs at the prompt. There is no output but you will see the checkbox "Give me updates for Microsoft products and check for new optional Microsoft software when I update Windows" inside the Windows Update settings dialog.

  5. rx74ray says:

    Great post, thanks!

  6. Fábio says:

    Wonderfull job!!!
    This script is usefull with Office 2013 after using a image disk with sysprep.
    sysprep killed Microsoft Update in Windows Update.

  7. Patrick says:

    You may use PowerShell to achive the same. Although it did not work for me on a Server 2012 R2 (IsPendingRegistrationWithAU = $true)

    No need to create a file. Simply paste in elevated PowerShell prompt:

    $ServiceManager = New-Object -ComObject "Microsoft.Update.ServiceManager"
    $ServiceManager.ClientApplicationID = "My App"
    $ServiceManager.AddService2( "7971f918-a847-4430-9279-4a52d1efe18d",7,"")

  8. dmj says:

    Just wanted to say thank you for this script. I had never seen this problem before and was kinda’ lost.

  9. MisterNT says:

    Great post – script worked perfectly. Had never gotten around to researching this particular, occasional annoyance.

  10. Steven Short says:

    did anyone get this to work with powershell? I’m getting the same issue as Patrick

  11. Jim says:

    Attempt on Windows 7 box and WindowsUpdate.log shows Windows Update states "AU is not configured" am I missing a step? Would like to launch a script to enable Windows Update and start pulling updates, then install.

  12. Pedro says:

    Thank you so much! This solved my problem on a Vista computer. I used the Powershell version posted by Patrick and it worked fine.

  13. JG Perez says:

    Doing a Win7U X64 reinstall with slipsteamed SP1 & most recent patches and kept getting sent to that useless page others have referred to here when I tried to change to Microsoft supdate. Your scipt worked perfectly oc I saw the instructions on how to
    ave and run it in the comments. Thank you.

  14. walter says:

    Patrick’s solution worked great:

    Simply paste in elevated PowerShell prompt:

    $ServiceManager = New-Object -ComObject "Microsoft.Update.ServiceManager"
    $ServiceManager.ClientApplicationID = "My App"
    $ServiceManager.AddService2( "7971f918-a847-4430-9279-4a52d1efe18d",7,"")

  15. Marty says:

    Thank you very much. That script restored the update option for Office 2010 on a Windows 7 computer. I have no idea why that option was missing in the first place.

  16. Mickael Bonjour says:

    For me it doesn’t enable Microsoft Update (via vbs or Powershell…)
    I have Windows 7 Pro x64 with last updates on 15.12.15

  17. Bavo D says:

    Patrick’s powershell script worked perfectly on my win7 pro x86! Thanks a lot Patrick!

  18. Jonathan Tremblay says:

    The script worked for me (Windows 7 64 Home edition). I was having a hard time with this option after a fresh install of Windows 7 (without Explorer 9). Thanks danbuche and Internet Exploder!