次の方法で共有


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: 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

  • Anonymous
    January 01, 2003
    @Ove - May be this is helpful? myitforum.com/.../workaround-for-installing-office-updates-during-an-image-build

  • Anonymous
    July 29, 2010
    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

  • Anonymous
    September 22, 2012
    This helped me fix my machine which I had updated from Win7 to Win8 and was unable to get WU to work.  Thank you.

  • Anonymous
    April 16, 2014
    Worked perfectly

  • Anonymous
    June 26, 2014
    The comment has been removed

  • Anonymous
    September 19, 2014
    Great post, thanks!

  • Anonymous
    November 04, 2014
    Wonderfull job!!!
    This script is usefull with Office 2013 after using a image disk with sysprep.
    sysprep killed Microsoft Update in Windows Update.

  • Anonymous
    November 11, 2014
    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,"")

  • Anonymous
    January 24, 2015
    Just wanted to say thank you for this script. I had never seen this problem before and was kinda' lost.

  • Anonymous
    March 10, 2015
    Great post - script worked perfectly. Had never gotten around to researching this particular, occasional annoyance.

  • Anonymous
    May 14, 2015
    did anyone get this to work with powershell? I'm getting the same issue as Patrick

  • Anonymous
    May 29, 2015
    The comment has been removed

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

  • Anonymous
    August 08, 2015
    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.

  • Anonymous
    October 27, 2015
    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,"")

  • Anonymous
    October 31, 2015
    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.

  • Anonymous
    December 15, 2015
    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

  • Anonymous
    December 18, 2015
    Patrick's powershell script worked perfectly on my win7 pro x86! Thanks a lot Patrick!

  • Anonymous
    January 07, 2016
    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!