Mark Minasi's Reader Forum
Mark Minasi's Reader Forum
Home | Profile | Register | Active Topics | Active Polls | Members | Search | FAQ | Minasi Forum RSS Feed
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old, obsolete or unused
 Scripting Archive
 Find HotFix
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dan.Yardman
Welcome Newcomer

USA
22 Posts
Status: offline

Posted - 12/03/2008 :  12:32:54 PM  Show Profile  Reply with Quote
I am trying to put together a script that will query the registry for a specify hotfix and then have the results directed to a text file. I am able to get an output, but is is of everything. I am only looking for an output of the hotfix, installed date and installed by. Does anyone know how I can limit the results to just the information that I need? Thank You.

mm_0_mm
Old Timer

USA
561 Posts
Status: offline

Posted - 12/03/2008 :  1:36:40 PM  Show Profile  Reply with Quote
Are you looking for something like this??


:loop
cls
if "%1" =="" set /P hotfix="Enter hotfix you want to query?  (KBxxxxxx)"
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Hotfix\%1%hotfix%" >results.txt
set hotfix=
notepad results.txt
goto loop



you can enter the desired KB as a parameter to the batch. If the parameter doesn't exist it will prompt you. Pressing enter will dump all the hotfix keys.

Edited by - mm_0_mm on 12/03/2008 1:38:00 PM
Go to Top of Page

Dan.Yardman
Welcome Newcomer

USA
22 Posts
Status: offline

Posted - 12/05/2008 :  2:57:13 PM  Show Profile  Reply with Quote
Thank you for your reply.
I was able to make some modifications to get what I needed. see script below.
---Script---
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB925902'",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "HotFixID: " & objItem.HotFixID
Wscript.Echo "InstalledBy: " & objItem.InstalledBy
Wscript.Echo "InstalledOn: " & objItem.InstalledOn

Next


I now have two new issues. 1. When a patch is missing, it gives me nothing, how do I get it to indicate that the patching is not installed. 2. Also, the output continue to show "Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved."
How do I squash that portion of the output. see Output text below.


---Output Text---
-----------------------------------
CSName: Hostname
HotFixID: KB925902
InstalledBy: Username
InstalledOn: 10/28/2008
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.


-----------------------------------
Go to Top of Page

mm_0_mm
Old Timer

USA
561 Posts
Status: offline

Posted - 12/05/2008 :  3:09:34 PM  Show Profile  Reply with Quote
run your script with "Cscript scriptname.vbs //Nologo"

if you add //s it will save //Nologo as the default for the current user.
Go to Top of Page

arek73
Honorable But Hopeless Addict

Poland
4642 Posts
Status: offline

Posted - 12/05/2008 :  4:53:58 PM  Show Profile  Visit arek73's Homepage  Click to see arek73's MSN Messenger address  Reply with Quote
Check out here:
http://msmvps.com/blogs/athif/archive/2005/11/20/76035.aspx

----
Arek
Go to Top of Page

Dan.Yardman
Welcome Newcomer

USA
22 Posts
Status: offline

Posted - 12/10/2008 :  2:28:28 PM  Show Profile  Reply with Quote
Thank you for all your help.
only one piece of the puzzle missing. How do I get it display a message when the hotfix does not exist?
Go to Top of Page

mm_0_mm
Old Timer

USA
561 Posts
Status: offline

Posted - 12/10/2008 :  3:26:54 PM  Show Profile  Reply with Quote
how about this?


strComputer = "." 
count = 0
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_QuickFixEngineering WHERE HotFixID = 'KB925902'",,48) 
For Each objItem in colItems 
count=count + 1
Wscript.Echo "-----------------------------------"
Wscript.Echo "HotFixID: " & objItem.HotFixID
Wscript.Echo "InstalledBy: " & objItem.InstalledBy
Wscript.Echo "InstalledOn: " & objItem.InstalledOn

Next
if  count = 0 then
	wscript.echo "Patch does not exist!"
end if
Go to Top of Page

Dan.Yardman
Welcome Newcomer

USA
22 Posts
Status: offline

Posted - 12/17/2008 :  12:02:16 PM  Show Profile  Reply with Quote
Thank you. I am getting the following error message "VBScript compilation error: Expected 'END' "

Is there a good book or books that you can recommend for someone who have never scripted before. I am mainly interested in querying Windows systems for information and based on the results, call another action, such as install something, delete something, output data to particular file, etc (you get the picture). It can be a WMI, vbscript C+, or basic batch scripting... Than you.
Go to Top of Page

mm_0_mm
Old Timer

USA
561 Posts
Status: offline

Posted - 12/17/2008 :  8:02:02 PM  Show Profile  Reply with Quote
I just copied the exact text and it works for me...are you sure you got the last line (end if)

I've never used a book, I just google for what I want to accomplish and modify to fit my needs. You can download scriptomatic from microsoft. It lets you choose items to query for and automatically writes the script...
Go to Top of Page

Playwell
Honorable But Hopeless Addict

Netherlands
4819 Posts
Status: offline

Posted - 12/17/2008 :  8:17:23 PM  Show Profile  Visit Playwell's Homepage  Click to see Playwell's MSN Messenger address  Reply with Quote
just offering a command prompt 1 liner option:
wmic qfe get |find /i "KB925902"

'People who think they know everything are a great annoyance to those of us who do. '
Quote by Isaac Asimov


Go to Top of Page

Xenophane
Honorable But Hopeless Addict

Denmark
3070 Posts
Status: offline

Posted - 12/18/2008 :  2:13:40 PM  Show Profile  Visit Xenophane's Homepage  Send Xenophane an ICQ Message  Reply with Quote
Ok, then I will add a oneliner as well


gwmi Win32_QuickFixEngineering | where {$_.HotFixID -match "KB925902"}

Microsoft Powershell MVP

SIG> George Bernard Shaw : The power of accurate observation is commonly called cynicism by those who have not got it. </SIG>

You can read my blog at www.xipher.dk
Go to Top of Page

Xenophane
Honorable But Hopeless Addict

Denmark
3070 Posts
Status: offline

Posted - 12/18/2008 :  2:44:03 PM  Show Profile  Visit Xenophane's Homepage  Send Xenophane an ICQ Message  Reply with Quote
Not pretty, but this will also translate the SID to username, and translate the InstalledOn (at least on Vista 64bit, where the valued is returned as a 64 bit Time format.


$a = gwmi Win32_QuickFixEngineering | where {$_.HotFixID -match "KB925902"}
$a
$objSID = New-Object System.Security.Principal.SecurityIdentifier `
    ($a.InstalledBy)
$objUser = $objSID.Translate( [System.Security.Principal.NTAccount])

Write-host "Translated SID"
$objUser.Value
Write-Host "Translated InstalledOn, on Vista 64 bit it is in the 64 Bit UTC date format"


 [datetime]::FromFileTimeUTC([Convert]::ToInt64($a.InstalledOn,16)) |

Microsoft Powershell MVP

SIG> George Bernard Shaw : The power of accurate observation is commonly called cynicism by those who have not got it. </SIG>

You can read my blog at www.xipher.dk
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Mark Minasi's Reader Forum © 2002-2011 Mark Minasi Go To Top Of Page
This page was generated in 0.11 seconds. Snitz Forums 2000