MSFN Forum: need help with .js script to hide updates - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

need help with .js script to hide updates Rate Topic: -----

#1 User is offline   biatche 

  • Member
  • PipPip
  • Group: Members
  • Posts: 194
  • Joined: 23-November 05

Posted 03 November 2011 - 01:17 AM

var updateSession = WScript.CreateObject("Microsoft.Update.Session");
var updateSearcher = updateSession.CreateUpdateSearcher();
updateSearcher.Online = false;

// this part must be changed? this is the language pack section. I want to search the entire database that isn't installed and filter by KB###### rather than category.
var searchResult = updateSearcher.Search("CategoryIDs Contains 'cd5ffd1e-e932-4e3a-bf74-18bf0b1bbd83' And IsInstalled=0");

for(var i=0; i<searchResult.Updates.Count; i++){
  var update = searchResult.Updates.Item(i);
  WScript.echo("Hiding:" + update.Title);
  update.IsHidden = true;
}


I can't work out how to modify this script so that it will hide certain specific updates filtered by KBtitle

such as KB2483139 KB915597 KB971033 KB890830

actually just these 4.

Thanks


#2 User is offline   ndog 

  • Group: Members
  • Posts: 7
  • Joined: 30-September 10
  • OS:none specified
  • Country: Country Flag

Posted 08 December 2011 - 05:25 AM

This is vbs which works for me. If you can convert to js then share with the rest of the world that would be nice

Function WuaVersion 'get current WUA version
  Dim oAgentInfo, ProductVersion
  On Error Resume Next 
  Err.Clear
  Set oAgentInfo = CreateObject("Microsoft.Update.AgentInfo")
  If ErrNum = 0 Then 
    WuaVersion = oAgentInfo.GetInfo("ProductVersionString") 
  Else 
    Wscript.Echo "Error getting WUA version."
    WuaVersion = 0 'calling code can interpret 0 as an error.
  End If 
  On Error Goto 0
End Function 

msgbox(WuaVersion)
if WuaVersion <> "0" then
    Set ServiceManager = CreateObject("Microsoft.Update.ServiceManager")
    ServiceManager.ClientApplicationID = "My App"

    'add the Microsoft Update Service, GUID
    Set NewUpdateService = ServiceManager.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"")
end if


'ServerSelection values
ssDefault = 0
ssManagedServer   = 1
ssWindowsUpdate   = 2
ssOthers          = 3

'InStr values
intSearchStartChar = 1


dim strTitle


Set updateSession = CreateObject("Microsoft.Update.Session")
Set updateSearcher = updateSession.CreateupdateSearcher()

updateSearcher.ServerSelection = ssWindowsUpdate
Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")


For I = 0 To searchResult.Updates.Count-1
    Set update = searchResult.Updates.Item(I)
    strTitle = update.Title
    if InStr(intSearchStartChar, strTitle, "KB971033", vbTextCompare) <> "0" then
    update.IsHidden = True
    end if
Next

WScript.Quit


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

2 User(s) are reading this topic
0 members, 2 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy