• 0

VBScript - Check to see if Microsoft Hoxfix (KB) is NOT installed


Question

Hello, I have an essential hotfix that has been deployed across our network, however it has not been installed on all the machines, and want to check which machines will need the hotfix.

 

Using VBScript, is there a way that a script that runs at startup that checks whether a specific KB is NOT installed and write the result as a file into a directory?

 

At the moment I have this:

On Error Resume Next
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_QuickFixEngineering",,48)
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set wshNetwork = WScript.CreateObject( "WScript.Network" )
strComputerName = wshNetwork.ComputerName
 
 
For Each objItem in colItems
 
If objItem.HotfixID = "KB2590550" then
 
outFile="\\F30-CHI\D$\VBTest\" & strComputerName
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Close
 
End If
 
Next

This works perfectly for creating a file if the Hofix IS installed. However I want it to create a file if it is NOT installed.

 

Is this possible?

2 answers to this question

Recommended Posts

  • 0

Add a new variable to store the 'found' state, this variable may store a value of 0 for not found and 1 for found, for example. Initialise it to 0. As you loop through the dataset you're analysing to detect whether the patch is installed, if and when the current object in the loop is the item you're looking for, change the 'found' variable state to 1 to indicate that it's been found. Once you've finished looping through the dataset and therefore have a result as to whether or not the item was found, you can then do something based on that information with a new if statement.

 

For sake of efficiency, you might also like to use a 'break' command to stop looping once you've found the item you're looking for. In VBScript there are multiple 'break' commands, each for breaking out of a different construct - 'Exit For', 'Exit Do', 'Exit Sub'.

patchFound = 0

For Each objItem in colItems
     If objItem.HotfixID = "KB2590550" then
        patchFound = 1
        Exit For
    End If
Next

If patchFound = 0 then
    //Do something (patch missing so install it...)
End If
This topic is now closed to further replies.
  • Posts

    • Larry likes animals.  Mommy acts sh!t
    • vPro is a platform that has features aimed at companies, remote management, security, threats detection, drivers that are stable for 15 months, and many other things. And this includes Core, Core Ultra (which are excellent), and a set of Xeon. And this exists for years, and a Intel platform also includes networking Ethernet and WiFi (this requires years of development), a host of security features, power management, storage technologies, This does not exist in such a complete and coherent platform at AMD… And. please, no Windows 10 PC is going to turn into dust in a second, there is 3 years of extended support… for old laptops, there is no reason not to switch, and that backup feature is unrelated.
    • When will the US stop the monster ? They ###### everyone, customers, victims, employees, all the suppliers: the story behind every hw parts is the same, acquired, outsourced, but poaching employees is the cheapest way. The narrative arcs from the last 15 years, all partially or entirely deceptive: security (they stopped with that one, not sustainable), privacy, with the secure cloud ahah, the local AI ahah, selling the user base to Google, ahah, that’s the privacy you will enjoy. Innovations, it became a running gag, when everything is average and years late. The competition: on macOs all their crappy services, 20 apps, that you cannot even hide. They have business practices that no other company could adopt, they would be sued, Apple, on a pedestal for being the greatest parasite company (they capture a lot of wealth, give nothing back, except tens of billion in buybacks every year). Ah, the M socs, they hit a wall (long ago) and still market them as having AAA gaming abilities, they do not, one more fraud. At least there is some fun, Apple building fabs in cooperation with TSMC… ahahahah how are they involved ? Catering ? They provide the cloths ? It’s really sad to see that in the US corruption and mediocrity have reached a level so that companies like Apple or Tesla are getting so much help and support from the administrations, and other entities… that they do not even try to hide today. I wonder when will we know how much the news outlets are being paid to regurgitate anything Apple wants.. This is decay and it’s ugly.
    • it might be a work or school thing. at my work, a disclaimer pops up stating that "you should use google chrome or edge for the best possible experience." at my school, the disclaimer says just to use google chrome. i'm sure a lot of IT guys just want to make it easy and tell employees to use google chrome because of the apparent trends in web developers testing and all. i'm sure that can have big ramifications on browser usage for average users since "if my IT dep permits it, then it's good". i liked that my work also stated Edge, but i've seen "use google chrome" a lot more without mentioning edge. matter of fact, my employer removed firefox from all devices.
  • Recent Achievements

    • Week One Done
      Ricky Chan earned a badge
      Week One Done
    • Week One Done
      maimutza earned a badge
      Week One Done
    • Week One Done
      abortretryfail earned a badge
      Week One Done
    • First Post
      Mr bot earned a badge
      First Post
    • First Post
      Bkl211 earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      483
    2. 2
      +FloatingFatMan
      263
    3. 3
      snowy owl
      240
    4. 4
      ATLien_0
      227
    5. 5
      Edouard
      188
  • Tell a friend

    Love Neowin? Tell a friend!