Overclock.net banner

Batch Update Uninstaller - Uninstall Forced Win10 & Telemetry

47K views 398 replies 39 participants last post by  Quantum Reality 
#1 ·
post-flame-small.gif
Batch Update Uninstaller v5.2.5
post-flame-small.gif



BatchUpdateUninstallerv5.2.5.zip 141k .zip file

Published March 16th, 2016
How to use:

  1. Run BatchUpdateUninstaller.cmd
  2. Type 1 and confirm.
  3. When the script completes, reboot. That's it!
    smile.gif

Recommendations:

  • It's highly recommended to set Windows Update to check for updates without downloading or installing, then uncheck Optional, and Microsoft Product updates.
  • To fully disable the remaining telemetry and CEIP that comes with Windows 7, 8.1, and 10, you can use Spybot Anti-Beacon.
  • Duplicate pending or old device updates can easily be removed. Here's my guide for using Device Remover.
  • Having issues with windows update? For Windows 8 users and above, Run Dism /Online /Cleanup-Image /RestoreHealth, then sfc /scannow until no errors are reported or up to three times, whichever comes first. Windows 7 does not use Dism commands, so use the System Update Readiness tool instead, then sfc /scannow. That solves whatever the problem may be the the majority of cases.
  • Our recommended text editor is Notepad++!
  • Want to view and manage the network traffic of all running processes? Check out NetLimiter!
    thumb.gif

Known issues:

  • Some updates such as KB2976978 are baked into different versions of Windows, and cannot be removed. KB2976978 cannot be removed from Windows 8 & 8.1.
  • Running Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase will make any currently installed updates permanently unable to be uninstalled.
  • I have insomnia and sometimes am too tired to update BUU when a new update needs blocking.

Current KB uninstall list:

Code:

Code:
To change what updates are uninstalled, you can add or remove KB IDs. One KB ID per line is all that is required for the script to function. Do not remove this line of text.
971033  - https://support.microsoft.com/en-us/kb/971033  - [Common Bug/Error/BSOD] [Win7] - Causes Windows to deactivate legitimate licences under certain circumstances.
2454826 - https://support.microsoft.com/en-us/kb/2454826 - [Common Bug/Error/BSOD] [Win7/Server 2008R2] - Claims to improve graphic performance, yet often causes crashes and BSODs.
2505438 - https://support.microsoft.com/en-us/kb/2505438 - [Common Bug/Error/BSOD] [Win7/Server 2008R2] - Claims to fix performance issues, yet often breaks fonts.
2882822 - https://support.microsoft.com/en-us/kb/2882822 - [Telemetry] [Win7SP1/Server 2008R2SP1] - Adds ITraceRelogger interface support.
2902907 - UPDATE REMOVED BY MS    https://bit.ly/1MftRyG - [MS Pulled] [Unknown] - KB ID previously used as a buggy WinXP MSE installer. Associated with telemetry updates, unanimously uninstalled.
2922324 - UPDATE REMOVED BY MS       NO SOURCE AVAILABLE - [MS Pulled] [Win7/8.1?] - Installed alongside telemetry updates. Pulled by MS.
2952664 - https://support.microsoft.com/en-us/kb/2952664 - [Get Win10] [Win7SP1] - Ease upgrade experience to the latest version of Windows.
2976978 - https://support.microsoft.com/en-us/kb/2976978 - [Telemetry] [Win8/8.1] - CEIP diagnostics and telemetry.
2976987 - UPDATE REMOVED BY MS       NO SOURCE AVAILABLE - [Get Win10] [Win7SP1/8.1] Update related to the 3035583 Get Windows X program.
2977759 - https://support.microsoft.com/en-us/kb/2977759 - [Telemetry] [Win7] - CEIP diagnostics and telemetry.
2990214 - https://support.microsoft.com/en-us/kb/2990214 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Enables you to upgrade to a later version of Windows.
2999226 - https://support.microsoft.com/en-us/kb/2999226 - [Unknown  ] [Win7SP1/8.1/Server 2008R2SP1/Server 2012R2] - Enables Win10 universal CRT on earlier versions of windows.
3012973 - UPDATE REMOVED BY MS    https://bit.ly/1X8u9K4 - [Get Win10] [Win7SP1/8.1] - Installs Get Windows X program.
3014460 - UPDATE REMOVED BY MS    https://bit.ly/1LR8BJS - [Get Win10] [Win7SP1/Server 2008R2SP1] - Enables you to upgrade to a later version of Windows.
3015249 - UPDATE REMOVED BY MS       NO SOURCE AVAILABLE - [Telemetry] [Win7SP1/8.1/Server 2008R2SP1/Server 2012R2] - Adds telemetry points to consent.exe and UAC.
3021917 - https://support.microsoft.com/en-us/kb/3021917 - [Telemetry] [Win7SP1] - CEIP diagnostics and telemetry.
3022345 - https://support.microsoft.com/en-us/kb/3022345 - [Telemetry] [Win7SP1/8.1/Server 2012R2] Installs CEIP diagnostics and telemetry. Replaced by KB3068708.
3035583 - https://support.microsoft.com/en-us/kb/3035583 - [Get Win10] [Win7SP1/8.1] - Installs Get Windows X program. Creates UAC backdoor.
3042058 - https://support.microsoft.com/en-us/kb/3042058 - [Telemetry] [Win7SP1/8.1/Server 2008R2SP1/Server 2012R2] - Updates cipher suite priority order. Contains Windows logon spying elements.
3044374 - https://support.microsoft.com/en-us/kb/3044374 - [Get Win10] [Win8.1/Server 2012R2] - Enables you to upgrade to Win10.
3046480 - https://support.microsoft.com/en-us/kb/3046480 - [Telemetry] [Win7SP1/8.1/Server 2008R2SP1/Server 2012R2] - Determines whether to migrate .NET 1.1 with upgrades to a later version of Windows.
3050265 - https://support.microsoft.com/en-us/kb/3050265 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to support upgrades to a later version of Windows.
3050267 - https://support.microsoft.com/en-us/kb/3050267 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to support upgrades to a later version of Windows.
3058168 - https://support.microsoft.com/en-us/kb/3058168 - [Get Win10] [Win8.1/Server 2012R2] - Enables KMS hosts to activate Win10.
3065987 - https://support.microsoft.com/en-us/kb/3065987 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to Windows Update Client. July 2015.
3064683 - https://support.microsoft.com/en-us/kb/3064683 - [Get Win10] [Win8.1] - Windows 8.1 OOBE modifications to reserve Windows 10.
3065988 - https://support.microsoft.com/en-us/kb/3065988 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to Windows Update Client July 2015.
3068708 - https://support.microsoft.com/en-us/kb/3068708 - [Telemetry] [Win7/8.1/Server 2008R2SP1/Server 2012R2] - Installs CEIP diagnostics and telemetry.
3072318 - https://support.microsoft.com/en-us/kb/3072318 - [Get Win10] [Win8.1] - Windows 8.1 OOBE modifications to reserve Windows 10.
3074677 - https://support.microsoft.com/en-us/kb/3074677 - [Get Win10] [Win7/8.1/Server 2008R2SP1/Server 2012R2] - Compatibility update for upgrading to Windows 10. June 25th, 2015.
3075249 - https://support.microsoft.com/en-us/kb/3075249 - [Telemetry] [Win7SP1/8.1/Server 2008R2SP1/Server 2012R2] - Adds telemetry points to consent.exe and UAC.
3075851 - https://support.microsoft.com/en-us/kb/3075851 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to Windows Update Client. August 2015
3075853 - https://support.microsoft.com/en-us/kb/3075853 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to Windows Update Client. August 2015.
3080149 - https://support.microsoft.com/en-us/kb/3080149 - [Telemetry] [Win7SP1/8.1/Server 2008R2SP1/Server 2012R2] - Updates CEIP diagnostics and telemetry match Win10.
3081437 - https://support.microsoft.com/en-us/kb/3081437 - [Get Win10] [Win7/8.1/Server 2008R2SP1/Server 2012R2] - Compatibility update for upgrading to Windows 10. August 18, 2015.
3081454 - https://support.microsoft.com/en-us/kb/3081454 - [Get Win10] [Win7/8.1/Server 2008R2SP1/Server 2012R2] - Compatibility update for upgrading to Windows 10. September 8, 2015.
3081954 - https://support.microsoft.com/en-us/kb/3081954 - [Telemetry] [Win7SP1] - Update for Work Folders improvements in Windows 7 SP1. Contains telemetry elements.
3086255 - https://support.microsoft.com/en-us/kb/3086255 - [Common Bug/Error/BSOD] [Win7SP1/Server 2008R2SP1/Win8.1/Server 2012R2] - Security update for the graphics component in Windows. Breaks SafeDisk.
3088195 - https://support.microsoft.com/en-us/kb/3088195 - [Telemetry] [Win7SP1/Server 2008R2SP1/Win8.1/Server 2012R2] - Security update for Windows Kernel. Reported to contain keylogger.
3083324 - https://support.microsoft.com/en-us/kb/3083324 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to Windows Update Client. September 2015.
3083325 - https://support.microsoft.com/en-us/kb/3083325 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to Windows Update Client. September 2015.
3083710 - https://support.microsoft.com/en-us/kb/3083710 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to Windows Update Client. October 2015.
3083711 - https://support.microsoft.com/en-us/kb/3083711 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to Windows Update Client. October 2015.
3090045 - https://support.microsoft.com/en-us/kb/3090045 - [Get Win10] [Win7/8.1/Server 2008R2SP1/Server 2012R2] - Windows Update for reserved devices.
3093983 - https://support.microsoft.com/en-us/kb/3093983 - [Get Win10] [Win7/8.1/Server 2008R2SP1/Server 2012R2] - Security update for Internet Explorer. IE spying.
3102810 - https://support.microsoft.com/en-us/kb/3102810 - [Get Win10] [Win7/Server 2008R2SP1] - High CPU usage occurs when installing and searching for updates. Windows 10 upgrade elements.
3102812 - https://support.microsoft.com/en-us/kb/3102812 - [Get Win10] [Win8.1/Server 2012R2] - High CPU usage occurs when installing and searching for updates. Windows 10 upgrade elements.
3112336 - https://support.microsoft.com/en-us/kb/3112336 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to Windows Update Client. December 2015.
3112343 - https://support.microsoft.com/en-us/kb/3112343 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to Windows Update Client. December 2015.
3123862 - https://support.microsoft.com/en-us/kb/3123862 - [Get Win10] [Win7SP1/8.1] - Updated capabilities to upgrade Windows 8.1 and Windows 7.
3135445 - https://support.microsoft.com/en-us/kb/3135445 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to Windows Update Client. February 2016.
3135449 - https://support.microsoft.com/en-us/kb/3135449 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to Windows Update Client. February 2016.
3138612 - https://support.microsoft.com/en-us/kb/3138612 - [Get Win10] [Win7SP1/Server 2008R2SP1] - Improvements to Windows Update Client. March 2016.
3138615 - https://support.microsoft.com/en-us/kb/3138615 - [Get Win10] [Win8.1/Server 2012R2] - Improvements to Windows Update Client. March 2016.
3139929 - https://support.microsoft.com/en-us/kb/3139929 - [Get Win10] [Win7/8.1/Server 2008R2SP1/Server 2012R2] - Security update for Internet Explorer. Implements Windows 10 ad generator into IE VIA bundled update KB3146449.
↓ ORIGINAL POST ↓

I'm trying to uninstall and hide some windows updates using the method shown here: https://superuser.com/questions/922068/how-to-disable-the-get-windows-10-icon-shown-in-the-notification-area-tray/922921#922921
Except I want it to include this list of updates: [isleaked.com is down for good] https://fix10.isleaked.com/oldwindows.html (Note: KB2990214 is listed twice under different OS versions).

I'm not a programmer. I know almost nothing of programming or code, except that it can be so amazingly complicated. Mad respect to those who dedicate their lives to this stuff. I couldn't do it.

I'll copy the whole post (minus one small typo) in case there is link rot in the future.
Quote:
There are various ways to remove the GWX promotion "interactively" (in GUI mode).
However, I prefer to do it programmatically / the scripted way.

On my Win7 environments (in "workgroup" mode) I'm using the below scripts to achieve the following:

"uninstall" any suspect windows update
"hide" it from future update runs
"BlockWindows10.bat":

Code:

Code:
ECHO OFF
REM --- remember to invoke from ELEVATED command prompt!
REM --- or start the batch with context menu "run as admin".
SETLOCAL

REM --- (as of 2015-08-28):
REM  KB3035583 - GWX Update installs Get Windows 10 app in Windows 8.1 and Windows 7 SP1
REM  KB3021917 - Update to Windows 7 SP1 for performance improvements
REM  KB3012973 - Upgrade to Windows 10 Pro

REM --- no longer blocking:
REM  KB2952664 - Compatibility update for upgrading Windows 7
REM  KB2976978 - Compatibility update for Windows 8.1 and Windows 8
REM  KB3022345 - Telemetry [Replaced by KB3068708]
REM  KB3068708 - Update for customer experience and diagnostic telemetry

REM --- uninstall updates
echo uninstalling updates ...
start "title" /b /wait wusa.exe /kb:3021917 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3035583 /uninstall /quiet /norestart
echo  - done.
timeout 10

REM --- hide updates
echo hiding updates ...
start "title" /b /wait cscript.exe "%~dp0HideWindowsUpdates.vbs" 3021917 3035583 3012973
echo  - done.

echo ... COMPLETED (please remember to REBOOT windows, now)
pause
REM --- EOF
"HideWindowsUpdates.vbs" (Kudo http://serverfault.com/a/341318):

Code:

Code:
'// Inspired by Colin Bowern: http://serverfault.com/a/341318
If Wscript.Arguments.Count < 1 Then
    WScript.Echo "Syntax: HideWindowsUpdates.vbs [KB1] [KB2] ..." & vbCRLF & _
        " - Example1: HideWindowsUpdates.vbs 3035583" & vbCRLF & _
        " - Example2: HideWindowsUpdates.vbs 3035583 3012973"
    WScript.Quit 1
End If

Dim objArgs
Set objArgs = Wscript.Arguments
Dim updateSession, updateSearcher
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()

Wscript.Stdout.Write "Searching for pending updates..." 
Dim searchResult
Set searchResult = updateSearcher.Search("IsInstalled=0")

Dim update, kbArticleId, index, index2
WScript.Echo CStr(searchResult.Updates.Count) & " found."
For index = 0 To searchResult.Updates.Count - 1
    Set update = searchResult.Updates.Item(index)
    For index2 = 0 To update.KBArticleIDs.Count - 1
        kbArticleId = update.KBArticleIDs(index2)

        For Each hotfixId in objArgs
            If kbArticleId = hotfixId Then
                If update.IsHidden = False Then
                    WScript.Echo "Hiding update: " & update.Title
                    update.IsHidden = True
                Else
                    WScript.Echo "Already hidden: " & update.Title
                End If          
            End If
        Next

    Next
Next
'// EOF
Ok so here is my bat file which I have renamed Remove WU Spyware:

Code:

Code:
ECHO OFF
REM --- remember to invoke from ELEVATED command prompt!
REM --- or start the batch with context menu "run as admin".
SETLOCAL

REM --- (as of 2015-09-06):
REM  KB2976978 - Telemetry for Win8/8.1
REM  KB3075249 - Telemetry for Win7/8.1
REM  KB3080149 - Telemetry for Win7/8.1
REM  KB3021917 - Telemetry for Win7
REM  KB3022345 - Telemetry
REM  KB3068708 - Telemetry
REM  KB3044374 - Get Windows 10 for Win8.1
REM  KB3035583 - Get Windows 10 for Win7sp1/8.1
REM  KB2990214 - Get Windows 10 for Win7
REM  KB2952664 - Get Windows 10 assistant
REM  KB3075853 - Update for "Windows Update" on Win8.1/Server 2012R2
REM  KB3065987 - Update for "Windows Update" on Win7/Server 2008R2
REM  KB3050265 - Update for "Windows Update" on Win7
REM  KB3075851 - Update for "Windows Update" on Win7
REM  KB2902907 - Description is not available

REM --- uninstall updates
echo uninstalling updates ...
start "title" /b /wait wusa.exe /kb:2976978  /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3075249 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3080149 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3021917 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3022345 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3068708 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3044374 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3035583 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:2990214 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:2952664 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3075853 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3065987 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:3050265 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:971033 /uninstall /quiet /norestart
echo  - next
start "title" /b /wait wusa.exe /kb:2902907 /uninstall /quiet /norestart
echo  - done.
timeout 10

REM --- hide updates
echo hiding updates ...
start "title" /b /wait cscript.exe "%~dp0HideWindowsUpdates.vbs" 2976978 3075249 3080149 3021917 3022345 3068708 3044374 3035583 2990214 2952664 3075853 3065987 3050265 971033 2902907
echo  - done.

echo ... COMPLETED (please remember to REBOOT windows, now)
pause
REM --- EOF
And here is my HideWindowsUpdates.vbs I have no idea how the syntax works here. It's too much to deduce with no experience by just looking at it.

The problem is I don't know what to do about the bit with "Example1 and Example2". What do I rename the examples? I deleted the lines since they were examples but that caused an unexpected end of file error. Was I supposed to keep the [KB1 [KB2] and continue on for the number of KB's I'm listing And instead use example 2 to list them? It's probably something simple, I just don't know the syntax.

Code:

Code:
// Inspired by Colin Bowern: http://serverfault.com/a/341318
If Wscript.Arguments.Count < 1 Then
    WScript.Echo "Syntax: HideWindowsUpdates.vbs [KB2976978] [KB3075249] [KB3080149] [KB3021917] [KB3022345] [KB3068708] [KB3044374] [KB3035583] [KB2990214] [KB2952664] [KB3075853] [KB3065987] [KB3050265] [KB3075851] [KB2902907] ..." & vbCRLF & _
    " - Example1: HideWindowsUpdates.vbs 3035583" & vbCRLF & _
    " - Example2: HideWindowsUpdates.vbs 3035583 3012973"
    WScript.Quit 1
End If

Dim objArgs
Set objArgs = Wscript.Arguments
Dim updateSession, updateSearcher
Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateUpdateSearcher()

Wscript.Stdout.Write "Searching for pending updates..." 
Dim searchResult
Set searchResult = updateSearcher.Search("IsInstalled=0")

Dim update, kbArticleId, index, index2
WScript.Echo CStr(searchResult.Updates.Count) & " found."
For index = 0 To searchResult.Updates.Count - 1
    Set update = searchResult.Updates.Item(index)
    For index2 = 0 To update.KBArticleIDs.Count - 1
        kbArticleId = update.KBArticleIDs(index2)

        For Each hotfixId in objArgs
            If kbArticleId = hotfixId Then
                If update.IsHidden = False Then
                    WScript.Echo "Hiding update: " & update.Title
                    update.IsHidden = True
                Else
                    WScript.Echo "Already hidden: " & update.Title
                End If          
            End If
        Next

    Next
Next
// EOF
EDIT: Now with more colors!
 

Attachments

See less See more
5
#3 ·
The example section you're referring to, was just a block of text that would be displayed if the .vbs was called with no arguments (i.e. kb numbers). Essentially telling the user that hey this is how this should be called. If you only deleted those two lines and left the _ on the line above, the script will throw an error as it's looking for the line to continue.
If you really want to leave those lines out, it should look like this for that section:

Code:

Code:
If Wscript.Arguments.Count < 1 Then
    WScript.Echo "Syntax: HideWindowsUpdates.vbs [KB2976978] [KB3075249] [KB3080149] [KB3021917] [KB3022345] [KB3068708] [KB3044374] [KB3035583] [KB2990214] [KB2952664] [KB3075853] [KB3065987] [KB3050265] [KB3075851] [KB2902907] ..."
    WScript.Quit 1
End If
And having all of those uninstall's hard coded...ugh.
 
#4 ·
Quote:
Originally Posted by agawthrop View Post

The example section you're referring to, was just a block of text that would be displayed if the .vbs was called with no arguments (i.e. kb numbers). Essentially telling the user that hey this is how this should be called. If you only deleted those two lines and left the _ on the line above, the script will throw an error as it's looking for the line to continue.
If you really want to leave those lines out, it should look like this for that section:

Code:

Code:
If Wscript.Arguments.Count < 1 Then
    WScript.Echo "Syntax: HideWindowsUpdates.vbs [KB2976978] [KB3075249] [KB3080149] [KB3021917] [KB3022345] [KB3068708] [KB3044374] [KB3035583] [KB2990214] [KB2952664] [KB3075853] [KB3065987] [KB3050265] [KB3075851] [KB2902907] ..."
    WScript.Quit 1
End If
And having all of those uninstall's hard coded...ugh.
Thank you!!
Look it worked!
biggrin.gif
(I think?)



What do you mean by "having all of those uninstall's hard coded"?
I read there are ID's you can link them to just in case there are new revisions made and rolled out, but that sounded like a lot of work.

EDIT: How did you get your code colored like that? Is there a way to select for different languages?
 
#5 ·
Quote:
Originally Posted by cookieboyeli View Post

What do you mean by "having all of those uninstall's hard coded"?
I read there are ID's you can link them to just in case there are new revisions made and rolled out, but that sounded like a lot of work.

EDIT: How did you get your code colored like that? Is there a way to select for different languages?
I would have stored the KB's in a text file and then in the batch file looped through the text file and uninstalled each KB. I would've used a similar process in the vbs file for hiding the updates as well. It would eliminate the need for editing the code every time a new KB needs to added to the list. Plus it would just look a lot cleaner.

As for the color coding, your batch script is color coded. I think the reason your vbs code block is not is because of the ' before the // on the first and last lines.
 
#6 ·
Quote:
Originally Posted by agawthrop View Post

Quote:
Originally Posted by cookieboyeli View Post

What do you mean by "having all of those uninstall's hard coded"?
I read there are ID's you can link them to just in case there are new revisions made and rolled out, but that sounded like a lot of work.

EDIT: How did you get your code colored like that? Is there a way to select for different languages?
I would have stored the KB's in a text file and then in the batch file looped through the text file and uninstalled each KB. I would've used a similar process in the vbs file for hiding the updates as well. It would eliminate the need for editing the code every time a new KB needs to added to the list. Plus it would just look a lot cleaner.

As for the color coding, your batch script is color coded. I think the reason your vbs code block is not is because of the ' before the // on the first and last lines.
That's a lot easier to look at with he colors.

Yea there was a lot of tedious copy pasting. I started wondering if that was really the most efficient way since the same thing is written so many times...
But remember, I just copy pasted this. I have no skills whatsoever in this subject, in fact I consider it a small miracle that I actually got so close before asking for help.

I am interested in rewriting it to work how you say though. I have no doubt I'll have to add to the list numerous times throughout the ages.
So precisely how would I start? I did have a basic batch file but I deleted it. Let me see if I can recreate it...

EDIT: It was basically this for all files:

Code:

Code:
start /w wusa.exe /uninstall /kb:2976978 /quiet /norestart
start /w wusa.exe /uninstall /kb:3075249 /quiet /norestart
start /w wusa.exe /uninstall /kb:3080149 /quiet /norestart
exit
But you're talking even mroe basic aren't you, like just:

Code:

Code:
KB2976978
KB3075249
KB3080149
And then the meat and potatoes goes elsewhere to be left alone.
 
#9 ·
So I've come up with the following bat file and vbs file along with a txt file that contains the list of updates. Please note that I have not been able to fully test as I am on Windows 10.

Batch File (UninstallWinUpdates.bat):

Code:

Code:
@echo off
cls
Title "Uninstall and Hide Windows Updates"

Set @kbList=%~dp0kbList.txt
Set @uhwuScript=%~dp0UninstallWinUpdates.vbs

goto verifyPrivileges

REM verifies that the CMD window has been opened with proper privileges
:verifyPrivileges
        ECHO Administrative privileges required. Verifying privileges...
        net session >nul 2>&1
        if %errorLevel% == 0 (
                ECHO Privileges verified.
                goto verifyKBList
        ) else (
                ECHO Pivileges not verified.  Please close CMD and run with administrator privileges.
                goto Exit
        )

REM verifies that the kbList text file exists
:verifyKbList
        ECHO Checking for list of Windows Updates (kbList.txt)...
        If exist %~dp0\kbList.txt (
                set @kbList=%~dp0kbList.txt
                goto uninstallUpdates
        ) else (
                ECHO The file kbList.txt is required for this program to run and should
                ECHO contain the list of KBs that are to be uninstalled and hidden.
                ECHO Each KB should be listed on a separate line. The file should be
                ECHO saved in the same directory as the .bat file.
                goto Exit
        )

REM calls vbscript to uninstall and hide updates listed in kbList.txt
:uninstallUpdates
        ECHO Launching UninstallWinUpdates.vbs...
        C:\Windows\SysWOW64\cscript.exe //nologo %@uhwuScript% %@kbList%
        ECHO Updates have been uninstalled and hidden.
        ECHO Please RESTART Windows now.
        goto Exit

:Exit
        ECHO This program will close in 30 seconds
        TIMEOUT /t 30
        Exit
VBScript File (UninstallWinUpdates.vbs):

Code:

Code:
On Error Resume Next
Dim fso, kbList, kb, kbID, kbArray()

'Pull the KBs from kbList.txt into an Array
Set fso = CreateObject("Scripting.FileSystemObject")
Set kbList = fso.OpenTextFile(WScript.Arguments(0))
i=0
Do Until kbList.AtEndOfStream
        'skips the first 3 lines of kbList.txt due to instructions
        If i <= 2 Then 
                kbList.ReadLine
        Else    
                kb = kbList.ReadLine
                Redim Preserve kbArray(i-3) 'i-3 because we skip the first three lines of text
                kbArray(i-3) = Left(kb,7)
        End If
        i = i+1
Loop

'Loop through each KB in list and uninstall if installed
WScript.Echo "Uninstalling Updates..."
For Each kbID in kbArray
        uninstallKb(kbID)
Next
Wscript.Echo "Updates have been Uninstalled."

'Hide the updates
WScript.Echo "Hiding Updates..."
hideUpdates(kbArray)
WScript.Echo "Updates have been hidden."

'Funtion to uninstall the KB
Function uninstallKb(kbID)
        Dim objShell
        If getKbID(kbID)= True Then
                Set objShell = CreateObject("wscript.shell")
                WScript.StdOut.Write "Uninstalling KB" & kbID & "..."
                objShell.Run "Cmd /c wusa.exe /uninstall /KB:" & kbID & " /quiet /norestart",,True
                If getKbID(kbID) Then
                        Wscript.Echo "Failed"
                Else
                        Wscript.Echo "Completed"
                End If
        Else
                Wscript.Echo "Update KB" & kbID & " is not installed."
        End If  
End Function

'Function to check if the current KB is installed
Function getKbID(kbID)
        Dim strComputer, objService, Items, Item
        strComputer = "."     
        Set objService = GetObject("winmgmts:{impersonateLevel=impersonate}!\\" & strComputer & "\root\cimv2")
        Set Items = objService.ExecQuery("Select * from Win32_QuickFixEngineering where HotFixID = 'KB" & kbID & "'")
        For Each Item in Items
                If InStr(UCase(Item.HotFixID),UCase("KB" & kbID)) > 0 Then
                        Installed = True
                End If
        Next
        If Installed Then
                getkbID = True
        Else
                getkbID = False
        End If
End Function

'Function searches for uninstalled KBs
'Credit for this function goes to someone else (not sure who?)
Function hideUpdates(kbArray)
        Dim uSession, uSearcher, uResults, uItem, uItemID, i2, i3
        Set uSession = CreateObject("Microsoft.Update.Session")
        Set uSearcher = uSession.CreateUpdateSearcher()
        Wscript.StdOut.Write "Searching for pending updates..."
        Set uResults = uSearcher.Search("IsInstalled=0")
        Wscript.Echo Cstr(uResults.Updates.Count) & " found."
        For i2 = 0 To uResults.Updates.Count - 1
                Set uItem = uResults.Updates.Item(i2)
                For i3 = 0 To uItem.KBArticleIDs.Count - 1
                        uItemID = uItem.KBArticleIDs(i3)
                        For Each kb in kbArray
                                If uItemID = kb Then
                                        If uItem.IsHidden = False Then
                                                Wscript.StdOut.Write "Hiding update KB" & kb & "..."
                                                uItem.IsHidden = True
                                                Wscript.Echo "Hidden"
                                        Else
                                                WScript.Echo "Update KB" & kb & " already hidden"
                                        End If
                                End If
                        Next
                Next
        Next
End Function
Text file (kbList.txt):

Code:

Code:
This file is used to store all of the KB article numbers and info.
The KB number must be first, and one KB per line
ex. 2976978 - Telemetry for Win8/8.1
2976978 - Telemetry for Win8/8.1
3075249 - Telemetry for Win7/8.1
3080149
3021917
3022345
3068708
I've also attached the files in a zipped folder.
EDIT: Made some minor corrections to code above and reattached the file.

UninstallUpdates.zip 3k .zip file
 

Attachments

#10 ·
It works really well. Much cleaner.

I tweaked it a little to reduce the delay to 8 seconds since that just seems right and added punctuation tor the exit message.

Batch File (UninstallWinUpdates.bat):

Code:

Code:
@echo off
cls
Title "Uninstall and Hide Windows Updates"

Set @kbList=%~dp0kbList.txt
Set @uhwuScript=%~dp0UninstallWinUpdates.vbs

goto verifyPrivileges

REM verifies that the CMD window has been opened with proper privileges
:verifyPrivileges
        ECHO Administrative privileges required. Verifying privileges...
        net session >nul 2>&1
        if %errorLevel% == 0 (
                ECHO Privileges verified.
                goto verifyKBList
        ) else (
                ECHO Pivileges not verified.  Please close CMD and run with administrator privileges.
                goto Exit
        )

REM verifies that the kbList text file exists
:verifyKbList
        ECHO Checking for list of Windows Updates (kbList.txt)...
        If exist %~dp0\kbList.txt (
                set @kbList=%~dp0kbList.txt
                goto uninstallUpdates
        ) else (
                ECHO The file kbList.txt is required for this program to run and should
                ECHO contain the list of KBs that are to be uninstalled and hidden.
                ECHO Each KB should be listed on a separate line. The file should be
                ECHO saved in the same directory as the .bat file.
                goto Exit
        )

REM calls vbscript to uninstall and hide updates listed in kbList.txt
:uninstallUpdates
        ECHO Launching UninstallWinUpdates.vbs...
        C:\Windows\SysWOW64\cscript.exe //nologo %@uhwuScript% %@kbList%
        ECHO Updates have been uninstalled and hidden.
        ECHO Please RESTART Windows now.
        goto Exit

:Exit
        ECHO This program will close in 8 seconds.
        TIMEOUT /t 8
        Exit
I reduced the KB list instruction to two lines only since it seemed obvious.
I think yours got cut off a bit but I completed it. Now I need to find a site or forum that analyzes updates as they come out so I know what new ones to block when they come out.

Text file (kbList.txt):

Code:

Code:
This file is used to store all of the KB article numbers and info.
The KB number must be first, and one KB per line.
2976978 - Telemetry for Win8/8.1
3075249 - Telemetry for Win7/8.1
3080149 - Telemetry for Win7/8.1
3021917 - Telemetry for Win7
3022345 - Telemetry
3068708 - Telemetry
3044374 - Get Windows 10 for Win8.1
3035583 - Get Windows 10 for Win7sp1/8.1
2990214 - Get Windows 10 for Win7
2952664 - Get Windows 10 assistant
3075853 - Update for "Windows Update" on Win8.1/Server 2012R2
3065987 - Update for "Windows Update" on Win7/Server 2008R2
3050265 - Update for "Windows Update" on Win7
3075851 - Update for "Windows Update" on Win7
2902907 - Description is not available
To make that work I tweaked the VBS script. I'm not 100% certain that it's adjusted to ignore 2 lines instead of 3 since there are some i3's and i2's at the bottom. They don't seem related though and don't have hyphens so I think it's good.

VBScript File (UninstallWinUpdates.vbs):

Code:

Code:
On Error Resume Next
Dim fso, kbList, kb, kbID, kbArray()

'Pull the KB's from kbList.txt into an Array
Set fso = CreateObject("Scripting.FileSystemObject")
Set kbList = fso.OpenTextFile(WScript.Arguments(0))
i=0
Do Until kbList.AtEndOfStream
        'skips the first 2 lines of kbList.txt due to instructions
        If i <= 2 Then 
                kbList.ReadLine
        Else    
                kb = kbList.ReadLine
                Redim Preserve kbArray(i-2) 'i-2 because we skip the first three lines of text
                kbArray(i-2) = Left(kb,7)
        End If
        i = i+1
Loop

'Loop through each KB in list and uninstall if installed
WScript.Echo "Uninstalling Updates..."
For Each kbID in kbArray
        uninstallKb(kbID)
Next
Wscript.Echo "Updates have been Uninstalled."

'Hide the updates
WScript.Echo "Hiding Updates..."
hideUpdates(kbArray)
WScript.Echo "Updates have been hidden."

'Funtion to uninstall the KB
Function uninstallKb(kbID)
        Dim objShell
        If getKbID(kbID)= True Then
                Set objShell = CreateObject("wscript.shell")
                WScript.StdOut.Write "Uninstalling KB" & kbID & "..."
                objShell.Run "Cmd /c wusa.exe /uninstall /KB:" & kbID & " /quiet /norestart",,True
                If getKbID(kbID) Then
                        Wscript.Echo "Failed"
                Else
                        Wscript.Echo "Completed"
                End If
        Else
                Wscript.Echo "Update KB" & kbID & " is not installed."
        End If  
End Function

'Function to check if the current KB is installed
Function getKbID(kbID)
        Dim strComputer, objService, Items, Item
        strComputer = "."     
        Set objService = GetObject("winmgmts:{impersonateLevel=impersonate}!\\" & strComputer & "\root\cimv2")
        Set Items = objService.ExecQuery("Select * from Win32_QuickFixEngineering where HotFixID = 'KB" & kbID & "'")
        For Each Item in Items
                If InStr(UCase(Item.HotFixID),UCase("KB" & kbID)) > 0 Then
                        Installed = True
                End If
        Next
        If Installed Then
                getkbID = True
        Else
                getkbID = False
        End If
End Function

'Function searches for uninstalled KBs
'Credit for this function goes to someone else (not sure who?)
Function hideUpdates(kbArray)
        Dim uSession, uSearcher, uResults, uItem, uItemID, i2, i3
        Set uSession = CreateObject("Microsoft.Update.Session")
        Set uSearcher = uSession.CreateUpdateSearcher()
        Wscript.StdOut.Write "Searching for pending updates..."
        Set uResults = uSearcher.Search("IsInstalled=0")
        Wscript.Echo Cstr(uAvail.Updates.Count) & " found."
        For i2 = 0 To uResults.Updates.Count - 1
                Set uItem = uResults.Updates.Item(i2)
                For i3 = 0 To uItem.KBArticleIDs.Count - 1
                        uItemID = uItem.KBArticleIDs(i3)
                        For Each kb in kbArray
                                If uItemID = kb Then
                                        If uItem.IsHidden = False Then
                                                Wscript.StdOut.Write "Hiding update KB" & kb & "..."
                                                uItem.IsHidden = True
                                                Wscript.Echo "Hidden"
                                        Else
                                                WScript.Echo "Update KB" & kb & " already hidden"
                                        End If
                                End If
                        Next
                Next
        Next
End Function
Now I was wondering, how viable is it to get some status feedback on each KB? Like:

Code:

Code:
KB3035583 has been uninstalled.
Or

Code:

Code:
KB3035583 is not installed/present.
That would take a crazy amount of work though right? You'd have to code separate "sections/things" to check if it's uninstalled or just hidden, and then setup messages accordingly. But one "section/thing" would be able to give feedback on whether or not it's installed or uninstalled since that's just a 0 or 1 right? And if checking each "status" is done similarly you could almost copy and paste sections to check/report hidden status and downloaded status. But I'm sure there's a way to switch between different statuses to check rather than make a new checking/status output section for each... so maybe it isn't a massive amount. What do you think?

The VBS file is wicked complicated and new to me, I can only decipher/deduce some of it.

EDIT: I've switched to Notepad++ from Notepad2. It's helping already since it color codes much better. It's got some cool themes too which are much easier to look at.
 
#11 ·
Oh I found something. When I click on the VBS directly a process starts and immediately uses 17.5% CPU usage and the system process uses 7%. So if I start it 4 times it will be close to 100% CPU usage.

Is this expected behavior?

If other people messed with this and didn't know they'd use up a lot of CPU usage until they rebooted. Took me an hour to notice I was at 98% CPU usage.
 
#12 ·
Quote:
Originally Posted by cookieboyeli View Post

It works really well. Much cleaner.

I tweaked it a little to reduce the delay to 8 seconds since that just seems right and added punctuation tor the exit message.

I reduced the KB list instruction to two lines only since it seemed obvious.
I think yours got cut off a bit but I completed it. Now I need to find a site or forum that analyzes updates as they come out so I know what new ones to block when they come out.

To make that work I tweaked the VBS script. I'm not 100% certain that it's adjusted to ignore 2 lines instead of 3 since there are some i3's and i2's at the bottom. They don't seem related though and don't have hyphens so I think it's good.

Now I was wondering, how viable is it to get some status feedback on each KB? Like:

Code:

Code:
KB3035583 has been uninstalled.
Or

Code:

Code:
KB3035583 is not installed/present.
That would take a crazy amount of work though right? You'd have to code separate "sections/things" to check if it's uninstalled or just hidden, and then setup messages accordingly. But one "section/thing" would be able to give feedback on whether or not it's installed or uninstalled since that's just a 0 or 1 right? And if checking each "status" is done similarly you could almost copy and paste sections to check/report hidden status and downloaded status. But I'm sure there's a way to switch between different statuses to check rather than make a new checking/status output section for each... so maybe it isn't a massive amount. What do you think?

The VBS file is wicked complicated and new to me, I can only decipher/deduce some of it.

EDIT: I've switched to Notepad++ from Notepad2. It's helping already since it color codes much better. It's got some cool themes too which are much easier to look at.
Changing the timeout to 8 seconds should work fine. I chose thirty to give you time to read through the results. As for the changes to the text file and the vbs. The text file makes sense, and I've made some changes to the vbs to correct a few things.

Line 5: removed ' from KBs

Code:

Code:
'Pull the KBs from kbList.txt into an Array
Line 11: changed from 2 to 1 since were skipping 2 lines instead of three. Starts with 0, so 0-1 would skip the first two lines.

Code:

Code:
If i <= 1 Then
Line 15: change the comment from three to two

Code:

Code:
Redim Preserve kbArray(i-2) 'i-2 because we skip the first two lines of text
Now on the status question, if you look at the functions uninstallKB and hideUpdates you'll see that it should be echoing the status for each. It's interesting that it's not doing that. Could you run the program and take a few screen shots of the it while its processing?

I've been using Notepad++ for a long time. I love it.

Quote:
Originally Posted by cookieboyeli View Post

Oh I found something. When I click on the VBS directly a process starts and immediately uses 17.5% CPU usage and the system process uses 7%. So if I start it 4 times it will be close to 100% CPU usage.

Is this expected behavior?

If other people messed with this and didn't know they'd use up a lot of CPU usage until they rebooted. Took me an hour to notice I was at 98% CPU usage.
As the VBS is not meant to be run on it's own (it won't have the kbList.txt file passed to it in an argument if you just run it) I'm not sure what the expected results would be. I could see it running up the usage since it's hanging trying to process data it doesn't have. Hope that answers that question.
 
#14 ·
Sorry for the delay. I would test this, but I accidentally associated .bat files with Notepad++ and cannot for the life of me fix that.
And everything still opens up with notepad unless I manually set it to open with Notepad++ (Yes I ran as admin).

Once I find a way to fix this I'll test the changes.
smile.gif


EDIT: GOT IT! http://www.eightforums.com/tutorials/8486-default-file-associations-restore-windows-8-a.html

Is there a way to set Notepad++ as the default editor like Notepad2 was?

By the way I had done this previously because I read the comment.
smile.gif

Code:

Code:
Redim Preserve kbArray(i-2) 'i-2 because we skip the first two lines of text
 
#15 ·


Sorry about creating another post, I meant to edit and wasn't paying attention.

EDIT: I also increased the exit delay to 10 seconds because there would have been more to read and it was a little tricky to screenshot. I felt like it.
tongue.gif


Not talking about the current issue, but is there any reason why this can't run on Windows 10 as well? I know none of the updates are for Windows 10, but surely in a few months some blacklist worthy updates will come out. Could I just add them to the list and run this on any OS?
 
#16 ·
I've never set notepad++ as the default editor, but it looks like there are a few methods of doing this: http://superuser.com/questions/474079/how-do-i-set-notepad-as-the-default-editor

I'm curious as to why the functions are not echoing the appropriate status info? I'm at work today so I can actually test it here.

As for Win10, I know that it will find updates, as that part worked on my personal machine.
 
#17 ·
So, after some trouble shooting today I figured out the problems.

The first issue was a typo in the getKbID function. This typo was causing the whole vbscript to essentially exit. Once I fixed that I was able to do some more troubleshooting and found a few more issues. The first being the call to run the command for the kb uninstall. It was causing a "Catastrophic Error" associated with trying to the the Windows Update service uninstaller in the wrong bit (32 or 64). Had to make changes to that function and the batch file, but once I got that fixed, I verified that it does now work and provides status updates. I then tested the hiding function. It had some flaws in logic as well as some other things. So i essentially rewrote that function. I then added a check at the beginning of the script that looks for arguments being passed, if it finds none it exits the script. This should solve the issue of it staying running if double clicked on or run without the proper arguments.

I'll post the updated code in code blocks below as well as attach an updated version of everything. My txt file will be different then yours, so you don't really need it.

Batch file (UninstallWinUpdates.bat):

Code:

Code:
@echo off
cls
Title "Uninstall and Hide Windows Updates"

Set @kbList=%~dp0\kbList.txt
Set @uhwuScript=%~dp0\UninstallWinUpdates.vbs
Set @sysNativePath=%windir%\SysNative\

goto verifyPrivileges

REM verifies that the CMD window has been opened with proper privileges
:verifyPrivileges
        ECHO Administrative privileges required. Verifying privileges...
        net session >nul 2>&1
        if %errorLevel% == 0 (
                ECHO Privileges verified.
                goto verifyKBList
        ) else (
                ECHO Pivileges not verified.  Please close CMD and run with administrator privileges.
                goto Exit
        )

REM verifies that the kbList text file exists
:verifyKbList
        ECHO Checking for list of Windows Updates (kbList.txt)...
        If exist %~dp0\kbList.txt (
                set @kbList=%~dp0kbList.txt
                goto uninstallUpdates
        ) else (
                ECHO The file kbList.txt is required for this program to run and should
                ECHO contain the list of KBs that are to be uninstalled and hidden.
                ECHO Each KB should be listed on a separate line. The file should be
                ECHO saved in the same directory as the .bat file.
                goto Exit
        )

REM calls vbscript to uninstall and hide updates listed in kbList.txt
:uninstallUpdates
        ECHO Launching UninstallWinUpdates.vbs...
        C:\Windows\SysWOW64\Cscript.exe //nologo //D //X %@uhwuScript% %@kbList% %@sysNativePath%
        ECHO Updates have been uninstalled and hidden.
        ECHO Please RESTART Windows now.
        goto Exit

:Exit
        ECHO This program will close in 10 seconds.
        TIMEOUT /t 10
        Exit
VBScript file (UninstallWinUpdates.vbs):

Code:

Code:
On Error Resume Next
'Kills script if ran with no arguments
If WScript.Arguments.Count < 1 Then
        Wscript.Quit
End if

Dim sysNativePath
sysNativePath = WScript.Arguments(1)

Dim fso, kbList, kb, kbID, kbArray()

'Pull the KBs from kbList.txt into an Array
Set fso = CreateObject("Scripting.FileSystemObject")
Set kbList = fso.OpenTextFile(WScript.Arguments(0))
i=0

Do Until kbList.AtEndOfStream
        'skips the first 2 lines of kbList.txt due to instructions
    If i <= 1 Then 
        kbList.ReadLine
    Else    
        kb = kbList.ReadLine
        Redim Preserve kbArray(i-2) 'i-2 because we skip the first two lines of text
        kbArray(i-2) = Left(kb,7)
    End If
    i = i+1
Loop

'Loop through each KB in list and uninstall if installed
WScript.Echo "Uninstalling Updates..."
For Each kbID in kbArray
        uninstallKb(kbID)
Next
Wscript.Echo "Updates have been Uninstalled."

'Hide the updates
WScript.Echo "Hiding Updates..."
hideUpdates(kbArray)
WScript.Echo "Updates have been hidden."

'Funtion to uninstall the KB
Function uninstallKb(kbID)
    Dim objShell, objExec
    If getKbID(kbID)= True Then
        Set objShell = CreateObject("Shell.Application")
        WScript.StdOut.Write "Uninstalling KB" & kbID & "..."
                objshell.ShellExecute "Cmd", "/c " & sysNativePath & "\wusa.exe /kb:" & kbID & " /uninstall /quiet /norestart","","runas",1
        If getKbID(kbID) Then
            Wscript.Echo "Failed"
        Else
            Wscript.Echo "Completed"
        End If
        Else
                Wscript.Echo "Update KB" & kbID & " is not installed."
        End If  
End Function

'Function to check if the current KB is installed
Function getKbID(kbID)
    Dim strComputer, objService, Items, Item
    strComputer = "."     
    Set objService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set Items = objService.ExecQuery("Select * from Win32_QuickFixEngineering where HotFixID = 'KB" & kbID & "'")
    For Each Item in Items
        If InStr(UCase(Item.HotFixID),UCase("KB" & kbID)) > 0 Then
            Installed = True
        End If
    Next
    If Installed Then
        getkbID = True
    Else
        getkbID = False
    End If
End Function

'Function searches for uninstalled KBs
Function hideUpdates(kbArray)
        Dim uSession, uSearcher, uResults, uItem, uItemID, i2, i3, found
        Set uSession = CreateObject("Microsoft.Update.Session")
        Set uSearcher = uSession.CreateUpdateSearcher()
        Wscript.StdOut.Write "Searching for pending updates..."
        Set uResults = uSearcher.Search("IsInstalled=0")
        Wscript.Echo Cstr(uResults.Updates.Count) & " found."
                For Each kb in kbArray
                        Found = False
                        Wscript.StdOut.Write "Searching pending updates for KB" & kb & "..."
                        For i2 = 0 To uResults.Updates.Count - 1
                                Set uItem = uResults.Updates.Item(i2)
                                If InStr(UCase(uItem.Title),UCase("KB" & kb)) = 0 Then
                                        'continue with script
                                Else
                                        Found = True
                                        If uItem.IsHidden = False Then
                                                Wscript.StdOut.Write "Hiding update..."
                                                uItem.IsHidden = True
                                                Wscript.Echo "Hidden"
                                        Else
                                                Wscript.Echo "Update is already hidden."
                                        End If
                                End If
                        Next
                        If found = False Then
                                WScript.Echo "No Such Update Found"
                        End If
        Next
End Function
Text file (kbList.txt):

Code:

Code:
This file is used to store all of the KB article numbers and info.
The KB number must be first, and one KB per line.
3087985 - Security Update for IE11 Win8.1 x64
3089023 - Update for IE Flash
Attached File:

UninstallUpdatesv2.0.zip 3k .zip file
 

Attachments

#18 ·
Ok it's showing this:



For each update it flashes a blank command prompt in front of the main window so you can't really read while it's going on. I can't find where to put the /quiet though because I don't know what that window comes from... Is it because the script sends commands to windows and that's them executing? If you can't get rid if it maybe there is an "on top" setting for the main window.

Unfortunately it failed to uninstall the two updates you listed. I checked and they were installed on 8/20/15. (Why did you pick those two updates?) Perhaps it's because I have Internet explorer unchecked in programs and features? I may have removed the package from the WinSxS folder too, but I doubt that should block installed updates from being uninstalled. But then again why would windows install these updates on 8/20/15 if I've had interned explorer uninstalled from the beginning?
arrowheadsmiley.png


Also, we have an "Update is already hidden" and a "hidden"
but not a "No/Some updates have been uninstalled" to oppose "Updates have been uninstalled". So if it fails or only some fail and you have a really long list that goes off the screen which you aren't watching intently then you can at least see the status at the end and scroll back to up see which updates are having issues. Of course that would require setting a long (60+ seconds) timeout with press any key to exit or maybe no timeout at all (but then running automatically on an unmanned system would be out of the question).

What do you think of all this?

I'm reading through it trying to see where/how I can add the "else" for the a failed status of "Updates have been Uninstalled" but it's just something that gets said at a certain point and not setup like the this:

Code:

Code:
Found = True
                                        If uItem.IsHidden = False Then
                                                Wscript.StdOut.Write "Hiding update..."
                                                uItem.IsHidden = True
                                                Wscript.Echo "Hidden"
                                        Else
                                                Wscript.Echo "Update is already hidden."
                                        End If
I tried...
redface.gif
 
#19 ·
Okay, here's what I've discovered. To uninstall the updates, it requires elevated privileges (run as admin) on that command. But we also need the script to wait unitl the uninstall is complete before continuing. Therein lies the problem, I could call the command using objShell.Run which provides the ability to tell it to wait for completion, but doesn't allow for elevated privileges. I've chosen to run the command using objShell.ShellExecute which allows for elevated privileges, but not a way to wait for the command to finish. I think what I need to do is set up a loop to check if they uninstall has finished or not before continuing.

All of that is why the updates are showing as failed, the uninstall process starts, but it checks if its uninstalled before it's finished. If you run it again, do you get the same result or do they show up as uninstalled? I had a similar issue while debugging but it eventually showed up uninstalled. I'm assuming it was due to the timing?

I'll make some tweaks to adjust what is printed in regards to if an uninstall or hiding fails. Also in that regard, we could actually log this info as we go so if their were failures, you can look at the log.
I'll look into that too.

Also, to hide the cmd window from popping up change the 1 to a 0 on the following line of the uninstallKb function:

Code:

Code:
objshell.ShellExecute "Cmd", "/c " & sysNativePath & "\wusa.exe /kb:" & kbID & " /uninstall /quiet /norestart","","runas",0
 
#20 ·
Changed to 0, popup hidden.

The uninstall fails every time. I've done it 3 times so far. It only gives it about a half second or less before continuing.
What a catch though!
redface.gif
That would drive me nuts, but I guess finding an alternate way can be part of the "fun".

A log! Excellent idea!
smile.gif
Then we can keep the exit delay at 10 seconds. Will a new log be created every time or will the old one be overwritten? If it's not then after running daily for a year the og would be pretty big, perhaps enough to freeze/crash notepad on opening! Clear entries after 30 days? This got complicated fast.
biggrin.gif


Oh! But in case someone IS actually looking at the screen, you can say "Press any key or program will exit in X seconds." And if they press a key the message disappears and they are left with everything else to look over. That's probably the best combo.

EDIT: So those are called "functions". I'd been calling them "sections/things" haha
Post 999
 
#25 ·
Got it. Thanks. That's interesting that it says it's required and cannot be uninstalled. I was able to uninstall that update at work. It is a security update to IE. I was just using those two to test since they were the most recently installed. I'll be reinstalling them later. You might try changing the txt file to the list you had before and seeing if it works. Obviously it's going to fail on the part that it has two instances running, but I think I may have a work around on that. Just can't test it here.
 
#26 ·
Try this for the VBScript file:

Code:

Code:
On Error Resume Next
'Kills script if ran with no arguments
If WScript.Arguments.Count < 1 Then
        Wscript.Quit
End if

Dim sysNativePath
sysNativePath = WScript.Arguments(1)

Dim fso, kbList, kb, kbID, kbArray()

'Pull the KBs from kbList.txt into an Array
Set fso = CreateObject("Scripting.FileSystemObject")
Set kbList = fso.OpenTextFile(WScript.Arguments(0))
i=0

Do Until kbList.AtEndOfStream
        'skips the first 2 lines of kbList.txt due to instructions
    If i <= 1 Then 
        kbList.ReadLine
    Else    
        kb = kbList.ReadLine
        Redim Preserve kbArray(i-2) 'i-2 because we skip the first two lines of text
        kbArray(i-2) = Left(kb,7)
    End If
    i = i+1
Loop
kbList.Close

Dim numUpdates
numUpdates = i-3

'Loop through each KB in list and uninstall if installed
Dim iFail
iFail = 0
WScript.Echo "Uninstalling" & numUpdates & " Updates..."
For Each kbID in kbArray
        If Not uninstallKb(kbID) Then
                iFail = iFail + 1
        End If
Next
If iFail > 0 Then
        Dim numSuccess
        numSuccess = numUpdates - iFail
        WScript.Echo numSuccess & " updates have been uninstalled."
        WScript.Echo iFail & " updates failed to uninstall."
Else
        Wscript.Echo "All updates have been uninstalled."
End If

'Hide the updates
WScript.Echo "Hiding Updates..."
If hideUpdates(kbArray) Then
        WScript.Echo "Updates have been hidden."
Else
        WScript.Echo "Some updates were hidden."
End If

'Funtion to uninstall the KB
Function uninstallKb(kbID)
    Dim objShell, objExec, uFail
        If getKbID(kbID)= True Then
        Set objShell = CreateObject("Shell.Application")
        WScript.StdOut.Write "Uninstalling KB" & kbID & "..."
                objshell.ShellExecute "Cmd", "/c " & sysNativePath & "\wusa.exe /kb:" & kbID & " /uninstall /quiet /norestart","","runas",0
        Do 
                        WScript.Sleep 5000 'wait 5 seconds before checking if uninstall is complete
                Loop Until stillRunning = False
                If getKbID(kbID) Then
            Wscript.Echo "Failed"
                        uFail = True
        Else
            Wscript.Echo "Completed"
        End If
        Else
                Wscript.Echo "Update KB" & kbID & " is not installed."
        End If  
        If ufail Then
                uninstallKb = False
        Else
                uninstallKb = True
        End If
End Function

'Function to see if the uninstall command is still processing
Function stillRunning
        Set service = GetObject("winmgmts:")
        For Each process in service.InstancesOf("Win32_Process")
                If process.Name = "wusa.exe" Then
                        running = True
                        Exit For
                End If
        Next
        If running Then
                stillRunning = True
        Else
                stillRunning = False
        End If
End Function

'Function to check if the current KB is installed
Function getKbID(kbID)
    Dim strComputer, objService, Items, Item
    strComputer = "."     
    Set objService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set Items = objService.ExecQuery("Select * from Win32_QuickFixEngineering where HotFixID = 'KB" & kbID & "'")
    For Each Item in Items
        If InStr(UCase(Item.HotFixID),UCase("KB" & kbID)) > 0 Then
            Installed = True
        End If
    Next
    If Installed Then
        getkbID = True
    Else
        getkbID = False
    End If
End Function

'Function searches for uninstalled KBs
Function hideUpdates(kbArray)
        Dim uSession, uSearcher, uResults, uItem, uItemID, i2, i3, found
        Set uSession = CreateObject("Microsoft.Update.Session")
        Set uSearcher = uSession.CreateUpdateSearcher()
        Wscript.StdOut.Write "Searching for pending updates..."
        Set uResults = uSearcher.Search("IsInstalled=0")
        Wscript.Echo Cstr(uResults.Updates.Count) & " found."
                For Each kb in kbArray
                        Found = False
                        Wscript.StdOut.Write "Searching pending updates for KB" & kb & "..."
                        For i2 = 0 To uResults.Updates.Count - 1
                                Set uItem = uResults.Updates.Item(i2)
                                If InStr(UCase(uItem.Title),UCase("KB" & kb)) <> 0 Then
                                        Found = True
                                        If uItem.IsHidden = False Then
                                                Wscript.StdOut.Write "Hiding update..."
                                                uItem.IsHidden = True
                                                Wscript.Echo "Hidden"
                                        Else
                                                Wscript.Echo "Update is already hidden."
                                        End If
                                        Exit For
                                End If
                        Next
                        If found = False Then
                                WScript.Echo "No Such Update Found"
                                hideUpdates = False
                        Else
                                hideUpdates = True
                        End If
        Next
End Function
 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top