Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Batch Update Uninstaller - Uninstall Forced Win10 & Telemetry
New Posts  All Forums:Forum Nav:

Batch Update Uninstaller - Uninstall Forced Win10 & Telemetry - Page 2

post #11 of 399
Thread Starter 
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.
post #12 of 399
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:
KB3035583 has been uninstalled.

Or
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:
'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:
If i <= 1 Then
Line 15: change the comment from three to two
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.
Edited by agawthrop - 9/7/15 at 7:22pm
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
post #13 of 399
The status of the KB's should be showing something like this (Note: I did not run the hideUpdates function during this test):

First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
post #14 of 399
Thread Starter 
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:
Redim Preserve kbArray(i-2) 'i-2 because we skip the first two lines of text

Edited by cookieboyeli - 9/8/15 at 12:06am
post #15 of 399
Thread Starter 


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?
Edited by cookieboyeli - 9/8/15 at 12:04am
post #16 of 399
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.
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
post #17 of 399
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:
@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:
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:
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
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
post #18 of 399
Thread Starter 
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:
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
post #19 of 399
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:
objshell.ShellExecute "Cmd", "/c " & sysNativePath & "\wusa.exe /kb:" & kbID & " /uninstall /quiet /norestart","","runas",0

Edited by agawthrop - 9/8/15 at 9:28pm
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
First Build
(12 items)
 
  
CPUMotherboardGraphicsRAM
Intel Core i5 4690K Asus Z97-A Gigabyte GeForce GTX 970 mini Crucial 8GB 
Hard DriveHard DriveOptical DriveOS
Samsung SSD 840 EVO 250GB Western Digital Blue 1TB LG DVD Burner Windows 8.1 Pro 
KeyboardPowerCaseMouse
Logitech K800 Seasonic 550W Corsair Carbide SPEC-02 Logitech G700s 
  hide details  
Reply
post #20 of 399
Thread Starter 
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
Edited by cookieboyeli - 9/8/15 at 10:02pm
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Batch Update Uninstaller - Uninstall Forced Win10 & Telemetry