Advertisement
Guest User

jebacupdaty.vbs

a guest
Jul 25th, 2015
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'This script can be used to hide a driver if it is causing problems on your machine, you have uninstalled it, and you want to prevent Windows Update from reinstalling it
  2. Set updateSession = CreateObject("Microsoft.Update.Session")
  3.  updateSession.ClientApplicationID = "MSDN Sample Script to Hide drivers"
  4.  
  5. WScript.Echo "This script allows you to 'hide' selected drivers so Windows Update will not auto-install them" & vbCr & vbLf & _
  6.    "This is not normally recommended, but can be used for troubleshooting or support" & vbCr & vbLf & _
  7.    "Note: This script must be run elevated (run as admin) to work properly - else (un)hiding will fail with a cryptic error message" & vbCr & vbLf & vbLf & _
  8.    "Searching for applicable drivers..."
  9.  
  10. 'Find all applicable drivers
  11. Set updateSearcher = updateSession.CreateupdateSearcher()
  12.  Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Driver'")
  13.  If searchResult.Updates.Count = 0 Then
  14.     WScript.Echo "No applicable drivers..."
  15.     WScript.Quit
  16.  End If
  17.  
  18. 'Cycle through applicable drivers and offer to (un)hide each one
  19. For i = 0 To searchResult.Updates.Count-1
  20.     Set update = searchResult.Updates.Item(i)
  21.     currentState = "(currently not hidden)"
  22.     If (update.IsHidden <> 0) Then
  23.       currentState = "(currently hidden)"
  24.     End If
  25.     WScript.Echo "Type 'y' and then hit Enter to hide update " & update.Title & " " & currentState & ": "
  26.     hide = WScript.StdIn.Readline
  27.     If hide = "y" Then
  28.       If (update.IsHidden <> 1) Then
  29.         update.IsHidden = 1
  30.       End If
  31.     Else
  32.       If (update.IsHidden <> 0) Then
  33.         update.IsHidden = 0
  34.       End If
  35.     End If  
  36.  Next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement