need script to automatically hide updates via the DataStore.edb file

elliot7

New member
Local time
7:54 PM
Messages
1
Let's say I have several different updates I know I don't want. For example:
KB2952664 KB2976978 KB2977759 KB2990214 KB3021917 KB3035583

After a fresh install of Windows 7, there are a few hundred updates to be installed. I don't want to have to manually compare each update to my list of unwanted updates...

I would like a script or batch file which I can run before running Windows update for the first time, which will automatically mark these updates as hidden in the DataStore.edb file, so that I can just run all the updates without having to manually hide my unwanted updates.

It looks like maybe a solution can be put together using this information:

Mark A. Ziesemer: Scripted hiding of Windows Updates under Vista

This is slightly above my level of competence. Can anyone who is more familiar with this environment please comment as to how easy it would be to do what I want here?

Thank you!
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 7 Ultimate x64
Hi Elliot,

Give the script below a try. Note that it may take a few moments for the Windows Update, Control Panel item to reflect changes the script makes.


HideUpdates.js
Code:
KB_list = "KB2952664 KB2976978 KB2977759 KB2990214 KB3021917 KB3035583"
KB_list = KB_list.split(' ')
 
function forceUseCScript() {
    if (WScript.FullName.slice(-11).toLowerCase() != 'cscript.exe') {
        var WshShell = new ActiveXObject('WScript.Shell')
        WshShell.Run('%ComSpec% /k "CScript.exe /nologo ' + '"' + WScript.ScriptFullName + '""', 1, false)
        WScript.Quit()
    }
}
 
function promptForElevation() {
    if (WshShell.Run('Net Sess', 0, true) != 0) {
        new ActiveXObject('Shell.Application').ShellExecute('WScript', '"' + WScript.ScriptFullName + '"', '', 'RunAs', 1)
        WScript.Quit()
    }
}
 
function remove_non_numeric(string) {
    return string.replace(/\D/g,'')
}
 
var WshShell = new ActiveXObject('WScript.Shell')
promptForElevation()
forceUseCScript()
 
KB_successfully_processed = {}
for (i in KB_list) {
    KB_successfully_processed[KB_list[i]] = false
}
 
var WU = new ActiveXObject('Microsoft.Update.Session')
var searcher = WU.CreateUpdateSearcher()
searcher.Online = false
criteria = "IsInstalled=0"
 
var search_results = searcher.Search(criteria).Updates
 
list_success = false; list_fail = false
for (i = 0; i < search_results.Count; i++) {
    for (j = 0; j < search_results.Item(i).KBArticleIDs.Count; j++) {
        for (k in KB_list) {
            if (remove_non_numeric(search_results.Item(i).KBArticleIDs(j)) == remove_non_numeric(KB_list[k])) {
                try {
                    //search_results.Item(i).IsHidden = true
                    WScript.Echo('Hid update ' + KB_list[k])
                    KB_successfully_processed[KB_list[k]] = true; list_success = true
                } catch (e) {
                    WScript.Echo('Unable to hide update ' + KB_list[k])
                    list_fail = true
                }
            }
        }
    }
}
/*
WScript.Echo('')
if (list_success) {
    WScript.Echo('\nUpdates hidden:')
    for (i in KB_successfully_processed) {
        if (KB_successfully_processed[i]) {WScript.Echo('\t'+i)}
    }
}
 
if (list_fail) {
    WScript.Echo('\nUpdates failed to hide:')
    for (i in KB_successfully_processed) {
        if (!KB_successfully_processed[i]) {WScript.Echo('\t'+i)}
    }
}
*/
 

My Computer My Computer

Computer type
PC/Desktop
OS
Windows 10, Windows 8.1 Pro, Windows 7 Professional, OS X El Capitan
Back
Top