| Author |
Topic  |
|
|
Dan.Yardman
Welcome Newcomer
USA
22 Posts
Status: offline |
Posted - 12/03/2008 : 12:32:54 PM
|
|
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
|
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 |
 |
|
|
Dan.Yardman
Welcome Newcomer
USA
22 Posts
Status: offline |
Posted - 12/05/2008 : 2:57:13 PM
|
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.
----------------------------------- |
 |
|
|
mm_0_mm
Old Timer
  
USA
561 Posts
Status: offline |
Posted - 12/05/2008 : 3:09:34 PM
|
run your script with "Cscript scriptname.vbs //Nologo"
if you add //s it will save //Nologo as the default for the current user. |
 |
|
|
arek73
Honorable But Hopeless Addict
    
Poland
4642 Posts
Status: offline |
|
|
Dan.Yardman
Welcome Newcomer
USA
22 Posts
Status: offline |
Posted - 12/10/2008 : 2:28:28 PM
|
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? |
 |
|
|
mm_0_mm
Old Timer
  
USA
561 Posts
Status: offline |
Posted - 12/10/2008 : 3:26:54 PM
|
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
|
 |
|
|
Dan.Yardman
Welcome Newcomer
USA
22 Posts
Status: offline |
Posted - 12/17/2008 : 12:02:16 PM
|
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. |
 |
|
|
mm_0_mm
Old Timer
  
USA
561 Posts
Status: offline |
Posted - 12/17/2008 : 8:02:02 PM
|
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... |
 |
|
|
Playwell
Honorable But Hopeless Addict
    
Netherlands
4819 Posts
Status: offline |
Posted - 12/17/2008 : 8:17:23 PM
|
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

|
 |
|
|
Xenophane
Honorable But Hopeless Addict
    
Denmark
3070 Posts
Status: offline |
Posted - 12/18/2008 : 2:13:40 PM
|
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 |
 |
|
|
Xenophane
Honorable But Hopeless Addict
    
Denmark
3070 Posts
Status: offline |
Posted - 12/18/2008 : 2:44:03 PM
|
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 |
 |
|
| |
Topic  |
|