What is wrong with my script?

Discussion in 'Scripting' started by Super Spartan, Sep 4, 2015.

  1. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    #1 Super Spartan, Sep 4, 2015
    Last edited by a moderator: Apr 20, 2017
    I used this guy's script and added some more updates to hide Windows 10 and Telemetry updates but when I run it I get this error:

    [​IMG]

    Here is the code I used:

    Code:
    Dim hideupdates(25)
    
    hideupdates(0) = "KB2505438"
    hideupdates(1) = "KB2670838"
    hideupdates(2) = "KB2952664"
    hideupdates(3) = "KB2976978"
    hideupdates(4) = "KB2977759"
    hideupdates(5) = "KB2990214"
    hideupdates(6) = "KB3021917"
    hideupdates(7) = "KB3022345"
    hideupdates(8) = "KB3035583"
    hideupdates(9) = "KB3044374"
    hideupdates(10) = "KB3064683"
    hideupdates(11) = "KB3065987"
    hideupdates(12) = "KB3065987-v2"
    hideupdates(13) = "KB3065988"
    hideupdates(14) = "KB3065988-v2"
    hideupdates(15) = "KB3068708"
    hideupdates(16) = "KB3072318"
    hideupdates(17) = "KB3075249"
    hideupdates(18) = "KB3075851"
    hideupdates(19) = "KB3075853"
    hideupdates(20) = "KB3080149"
    hideupdates(21) = "KB3083324"
    hideupdates(22) = "KB3083325"
    
    
    set updateSession = createObject("Microsoft.Update.Session")
    set updateSearcher = updateSession.CreateupdateSearcher()
    
    Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
    
    For i = 0 To searchResult.Updates.Count-1
    set update = searchResult.Updates.Item(i)
    For j = LBound(hideupdates) To UBound(hideupdates)
    'MsgBox hideupdates(j)
    if instr(1, update.Title, hideupdates(j), vbTextCompare) = 0 then
      'Wscript.echo "No match found for " & hideupdates(j)
    else
    Wscript.echo "Hiding " & hideupdates(j)
    update.IsHidden = True
    end if
    Next
    Next
    
    
    set updateSession = createObject("Microsoft.Update.Session")
    set updateSearcher = updateSession.CreateupdateSearcher()
    
    Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
    
    For i = 0 To searchResult.Updates.Count-1
    set update = searchResult.Updates.Item(i)
    For j = LBound(hideupdates) To UBound(hideupdates)
    'MsgBox hideupdates(j)
    if instr(1, update.Title, hideupdates(j), vbTextCompare) = 0 then
      'Wscript.echo "No match found for " & hideupdates(j)
    else
    Wscript.echo "Hiding " & hideupdates(j)
    update.IsHidden = True
    end if
    Next
    Next
    Can someone please fix the code for me

    Thank you
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    May seem daft but does it have owt to do with the number in the brackets not matching the last entry which is number 22


    Never seen the script before :confused:

    Probably not...

    It mentions line 43 ?
     
  3. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    #3 tnx, Sep 4, 2015
    Last edited: Sep 4, 2015
    Is this bit meant to appear twice ?

    On the MSNF site there is this

     
  4. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    #4 Super Spartan, Sep 4, 2015
    Last edited by a moderator: Apr 20, 2017
    (OP)
    So here is the latest code I tried and still gives the error:

    Code:
    Dim hideupdates(21)
    hideupdates(0) = "KB2505438"
    hideupdates(1) = "KB2670838"
    hideupdates(2) = "KB2952664"
    hideupdates(3) = "KB2976978"
    hideupdates(4) = "KB2977759"
    hideupdates(5) = "KB2990214"
    hideupdates(6) = "KB3021917"
    hideupdates(7) = "KB3022345"
    hideupdates(8) = "KB3035583"
    hideupdates(9) = "KB3044374"
    hideupdates(10) = "KB3064683"
    hideupdates(11) = "KB3065987"
    hideupdates(12) = "KB3065988"
    hideupdates(13) = "KB3068708"
    hideupdates(14) = "KB3072318"
    hideupdates(15) = "KB3075249"
    hideupdates(16) = "KB3075851"
    hideupdates(17) = "KB3075853"
    hideupdates(18) = "KB3080149"
    hideupdates(19) = "KB3083324"
    hideupdates(20) = "KB3083325"
    
    set updateSession = createObject("Microsoft.Update.Session")
    set updateSearcher = updateSession.CreateupdateSearcher()
    
    Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'")
    
    For i = 0 To searchResult.Updates.Count-1
    set update = searchResult.Updates.Item(i)
    For j = LBound(hideupdates) To UBound(hideupdates)
    'MsgBox hideupdates(j)
    if instr(1, update.Title, hideupdates(j), vbTextCompare) = 0 then
    'Wscript.echo "No match found for " & hideupdates(j)
    else
    Wscript.echo "Hiding " & hideupdates(j)
    update.IsHidden = True
    end if
    Next
    Next 
    
    [​IMG]
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    I may just install Win 7 on my test machine and check this out.

    Just for a laugh...

    What version of Win 7 are you using ?
     
  6. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    Windows 7 Pro SP1 x64
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  7. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60

    I will export pro from my image and test this out.

    I suppose this scrip should hide any updates, not just specific ones.
     
  8. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    It is supposed to hide the updates that I specified in the script.

    When I run it I do see it saying hiding XXXX update but after that it throws in that line 37 error

    If you could also try running Windows update and see if it did actually hide those updates that are in the script you'd do me a huge favor.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  9. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    I will see if it picks up those updates.

    This is an unmodified SP1 image so I am guessing it will need a bus load of updates.

    I was thinking of starting small, picking the very first update and trying that script to hide it. Then move on from there.
     
  10. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    yes sure any update would do as a test if you can figure out what that error is!

    I really appreciate what you're doing mate. Thank you so much!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  11. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    No worries fella. Thank me once we get it sorted...I just love messing

    Funny thing..
    It has been that long since I messed with Win 7 I got errors at the install, wrong key. And I was adding a pro key. Forgot all about the "ei.cfg" file...It still had Ultimate info on it...:death:
     
  12. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    you can always skip the key mate and use Windows Loader ;)
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  13. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    #13 tnx, Sep 4, 2015
    Last edited: Sep 4, 2015
    yep I know...

    I have my BIOS modded. I just add my own OEM folder. The ei.cfg file was the little problem. I was trying to install Pro with the Ultimate ei.cfg. I normally just delete that file altogether, but it has been so long I forgot....:31:

    Win 7 is in...HOW LONGGGGGGGGGGGGG to check for updates..

    Must be two bus loads of them..

    I am guessing you just saved that code as a .vbs file ?


    jeeeeeeeezzzz It's taking longer to check for updates than it was to install the darn thing.:sticktongue:

    :stereo:
     
  14. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    #14 tnx, Sep 4, 2015
    Last edited: Sep 5, 2015
    Well I don't even seem to be able to call the .vbs file

    I saved a script as 1.vbs, placed into C:\

    I opened command prompt,

    cd C:\
    cscript C:\1.vbs

    Not sure if that is how to call a .vbs file but nothing happens at all.

    Can you tell me exactly what file extensions you are using and how you are doing it....

    :eek:

    patients is a virtue

    I got a pop up window "Hiding" took 5 mins or so to pop up

    error....

    :weep:

    Well you can just richt click on the .vbs file and "Open With Command Prompt"
     
  15. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    yeah same here it takes a while for the script to actually appear on your screen but when it does, it hides a few updates then error.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  16. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    I think that guy who originally made that script doesn't know what he's doing since I contacted him as well but he hasn't replied for many days.

    I need to find another script
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  17. MrMagic

    MrMagic MDL Guru

    Feb 13, 2012
    6,015
    4,148
    210


    ??

    Who made the script?
     
  18. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  19. tnx

    tnx MDL Expert

    Sep 2, 2008
    1,695
    267
    60
    Well, I have tried a few times and got nowhere..

    :weep:
     
  20. Super Spartan

    Super Spartan MDL Expert

    May 30, 2014
    1,709
    990
    60
    Thanks a lot for trying. Guess all the pros here can offer no help as well :(
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...