Enable / Disable Windows Update from vbscript

I need to disconnect the windows update service from my installation. I already use vbscript to do some things, so I would like to do it in vbscript.

My knowledge of vbscript (or any other script language) is very limited, so ... can anyone help me with this? I'll be very grateful!

Thank.

+3
source share
3 answers

Thanks to Tomalak and Patrick Kuff. I really appreciate your help. I think this may be a good and complete answer.

Method 1: Prevents the automatic update service from starting automatically when the machine boots.

strComputer = "."  'could be any computer, not just the local one '
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name = 'wuauserv'")

For Each objService in colServiceList
  objService.ChangeStartMode("Disabled")
Next

2: " " "" " ". (MSDN NotificationLevel)

Const AU_DISABLED = 1

Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
Set objSettings = objAutoUpdate.Settings

objSettings.NotificationLevel = AU_DISABLED
objSettings.Save

. 1 , 2 , .

GUI:

  • 1: "" \ "" \ " ", " " "" "".
  • 2: \ , " ".
+6

, .

, :

Const SCHEDULED_INSTALLATION = 1

Set objAutoUpdate = CreateObject("Microsoft.Update.AutoUpdate")
Set objSettings = objAutoUpdate.Settings

objSettings.NotificationLevel = SCHEDULED_INSTALLATION
objSettings.Save

: http://www.microsoft.com/technet/scriptcenter/resources/tales/sg0705.mspx

+2

VBScript, WMI:

strComputer = "."  'could be any computer, not just the local one '
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name = 'wuauserv'")

For Each objService in colServiceList
  objService.ChangeStartMode("Disabled")
Next

Check out the Win32_Service WMI class documentation for what else can be done.

It would be easier to use sc.exe:

sc config wuauserv start = auto

Here is a snippet of what can do sc.exe:

C:\>sc config
Modifies a service entry in the registry and Service Database.
SYNTAX:
sc <server> config [service name] <option1> <option2>...
CONFIG OPTIONS:
NOTE: The option name includes the equal sign.
 type= <own|share|interact|kernel|filesys|rec|adapt>
 start= <boot|system|auto|demand|disabled>
 error= <normal|severe|critical|ignore>
 binPath= <BinaryPathName>
 group= <LoadOrderGroup>
 tag= <yes|no>
 depend= <Dependencies(separated by / (forward slash))>
 obj= <AccountName|ObjectName>
 DisplayName= <display name>
 password= <password>
+1
source

Source: https://habr.com/ru/post/1699662/


All Articles