pf100

WDU Windows Update check VBscript

Oct 1st, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. Set Test = GetObject("winmgmts:{impersonationLevel=impersonate}!\\").ExecQuery _
  2. ("select * from Win32_PingStatus where address = 'www.msftconnecttest.com'")
  3.  
  4. For Each Result in Test
  5. If Result.Statuscode = 0 Then
  6. Call Check_for_updates
  7. Wscript.quit
  8. Else
  9. result = MsgBox (_
  10. "Internet connection seems unavailable." & vbNewLine &_
  11. "Do you still want to check for updates?", vbYesNo + vbQuestion,_
  12. "No Internet connection")
  13.  
  14. Select Case result
  15. Case vbYes
  16. Call Check_for_updates
  17. Case vbNo
  18. WScript.Quit
  19. End Select
  20.  
  21. End If
  22. Next
  23. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. Sub Check_for_updates
  25. Set Job = CreateObject("Microsoft.Update.Session")
  26. Set Task = Job.CreateupdateSearcher()
  27. Set Result = Task.Search("IsInstalled=0 and Type='Software' and IsHidden=0")
  28.  
  29. If Result.Updates.Count = 0 Then
  30. WScript.Quit
  31. Else
  32. Total = Result.Updates.Count
  33. End If
  34. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. Special_1 = "KB2267602" 'Definition updates for Windows Defender
  36. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37. For Number = 0 To Result.Updates.Count-1
  38. Set Title = Result.Updates.Item (Number)
  39. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  40. If instr (Title, Special_1) <> 0 Then
  41. Createobject("wscript.shell").Run("""C:\Program Files\Windows Defender\MpCmdRun.exe"" ""-SignatureUpdate"""), 0
  42. Total = Total - 1
  43. End If
  44. Next
  45. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. If Total = 0 Then
  47. WScript.Quit
  48. End If
  49. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50. result = MsgBox (_
  51. "(" & Total & ") updates have been found." & vbNewLine &_
  52. "Do you want to run Windows Update MiniTool?", vbYesNo + vbQuestion,_
  53. "Updates are available")
  54.  
  55. Select Case result
  56. Case vbYes
  57. CreateObject("wscript.shell").run("""C:\the path to Windows Update MiniTool\wumt_x64.exe""")
  58. Case vbNo
  59. WScript.Quit
  60. End Select
  61. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  62. End Sub
  63. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advertisement
Add Comment
Please, Sign In to add comment