acmilan_11 发表于 2015-2-9 00:14

用脚本开启Microsoft Update的方法

本帖最后由 acmilan_11 于 2015-2-21 16:04 编辑

微软的官方网站(update.microsoft.com)也是用这个方法来开启6.0.6000、6.1.7600、6.2.9200的Microsoft Update的。
可是这个网站有个缺点:不支持IE11。由于IE11更改了UserAgent字符串,因此从IE11上点击如下这个链接时,会导向一个不可用的提示信息。当然可以添加兼容性视图,但是对于离线的应用来说还是不方便。微软在安装完Office 2007以后版本之后会自动开启Microsoft Update,但是一旦你时候取消了那个选项,想再找到这个选项就困难了。微软把Microsoft Update隐藏了起来。〔Win8.1终于修复了这一蛋疼的遗留问题〕另外,在安装Office 2003之后也不会开启Microsoft Update。

传统的开启方法:点那个链接。(需要Internet)


除非你点那个链接开启了Microsoft Update,否则WU设置选项里是不会有这个选项的。


开启之后,注意第三行的字样:已经有Microsoft Update了。


开启Microsoft Update以后:WU设置中出现了两个Microsoft Update选项。


这是PowerShell程序

以下是代码(手机上可能看不到,请用电脑查看):
# 开启Microsoft Update的PowerShell脚本
$ServiceManager = New-Object -ComObject "Microsoft.Update.ServiceManager"
$ServiceManager.ClientApplicationID = "My App"
$ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")' 开启Microsoft Update的VBScript脚本(核心代码)
Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager")
ServiceManager.ClientApplicationID = "My App"
Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")' 最终版VBScript程序(兼容UAC)

' Execute this program again with admin privilege (for UAC compatibility).
if WScript.Arguments.length = 0 Then
Dim objShell
Set objShell = CreateObject("Shell.Application")
objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
else
CALL MAIN()
end if

SUB MAIN() ' Program starts here

vReturn = MsgBox("Enable Microsoft Update for Windows Vista/7/8?",vbYesNo,"Microsoft Update")
if vReturn = vbYes then
Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager")
ServiceManager.ClientApplicationID = "My App"
Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")
MsgBox "Microsoft Update enabled. Try Windows Update again.",vbOKOnly,"Microsoft Update"
end if

END SUB ' Program ends here


cjy__05 发表于 2015-2-9 13:49

是否也可以用在8/8.1上呢?

acmilan_11 发表于 2015-4-23 17:47

本帖最后由 acmilan_11 于 2015-4-23 17:49 编辑

win8.1已经修复了这个bug,所以用不着这个脚本

marcohard 发表于 2016-9-11 13:07

针对旧版本系统的?

liupeisong 发表于 2017-9-20 17:51

解决了大问题

diy371 发表于 2018-2-12 22:22

赞一个先!收藏了!

wyjhby 发表于 2019-6-7 23:00

先收藏下来,谢谢分享

iwocool 发表于 2019-8-4 06:51

收藏了,技术贴
页: [1]
查看完整版本: 用脚本开启Microsoft Update的方法