Page 1 of 1

Disable windows update using PureBasic?

Posted: Tue Jun 05, 2018 1:01 pm
by stmdbe2019
How to do the same thing in PureBasic for Windows 10 home/pro?

Code: Select all

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

Const AU_DISABLED = 1

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

objSettings.NotificationLevel = AU_DISABLED
objSettings.Save

Re: Disable windows update using PureBasic?

Posted: Tue Jun 05, 2018 1:04 pm
by RSBasic
For example, you can use my library if you want to use WMI: viewtopic.php?f=27&t=70329

Re: Disable windows update using PureBasic?

Posted: Tue Jun 05, 2018 1:32 pm
by RSBasic
You can also disable the Windows Update services with sc.exe:

Code: Select all

EnableExplicit

;Disable and stop services
RunProgram("sc.exe", "stop wuauserv", "", #PB_Program_Hide | #PB_Program_Wait)
RunProgram("sc.exe", "config wuauserv start= disabled", "", #PB_Program_Hide | #PB_Program_Wait)
RunProgram("sc.exe", "stop BITS", "", #PB_Program_Hide | #PB_Program_Wait)
RunProgram("sc.exe", "sc config BITS start= disabled", "", #PB_Program_Hide | #PB_Program_Wait)

;Enable and start services
;RunProgram("sc.exe", "config BITS start= AUTO", "", #PB_Program_Hide | #PB_Program_Wait)
;RunProgram("sc.exe", "start BITS", "", #PB_Program_Hide | #PB_Program_Wait)
;RunProgram("sc.exe", "config wuauserv start= AUTO", "", #PB_Program_Hide | #PB_Program_Wait)
;RunProgram("sc.exe", "start wuauserv", "", #PB_Program_Hide | #PB_Program_Wait)
(administrator rights required)

Re: Disable windows update using PureBasic?

Posted: Tue Jun 05, 2018 6:57 pm
by VB6_to_PBx
RSBasic wrote:You can also disable the Windows Update services with sc.exe:

Code: Select all

EnableExplicit

;Disable and stop services
RunProgram("sc.exe", "stop wuauserv", "", #PB_Program_Hide | #PB_Program_Wait)
RunProgram("sc.exe", "config wuauserv start= disabled", "", #PB_Program_Hide | #PB_Program_Wait)
RunProgram("sc.exe", "stop BITS", "", #PB_Program_Hide | #PB_Program_Wait)
RunProgram("sc.exe", "sc config BITS start= disabled", "", #PB_Program_Hide | #PB_Program_Wait)

;Enable and start services
;RunProgram("sc.exe", "config BITS start= AUTO", "", #PB_Program_Hide | #PB_Program_Wait)
;RunProgram("sc.exe", "start BITS", "", #PB_Program_Hide | #PB_Program_Wait)
;RunProgram("sc.exe", "config wuauserv start= AUTO", "", #PB_Program_Hide | #PB_Program_Wait)
;RunProgram("sc.exe", "start wuauserv", "", #PB_Program_Hide | #PB_Program_Wait)
(administrator rights required)
Would that Code also Stop Microsoft Security Essentials anti-virus software from updating Virus definitions ?

Re: Disable windows update using PureBasic?

Posted: Tue Jun 05, 2018 7:00 pm
by RSBasic
Yes, because the virus definitions are loaded via Windows Update.
But there is a CMD command to load the virus definitions manually: %ProgramFiles%\Microsoft Security Essentials\MpCmdRun.exe -SignatureUpdate