Home All Groups Group Topic Archive Search About

Bulldog (Need help with script downloaded from script center)

Author
15 Jan 2009 9:37 PM
Bulldog Bill
I downloaded the below script for listing all software loaded on a client
station but when i run it undesr wscript or use the GUI I have to ok each
and every capture, I am trying to get a list of what is on the station and
get it output to a csv file if possible. I am new at all of this so any help
at all would be appreciated. thanks in advance>

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"
strEntry2 = "InstallDate"
strEntry3 = "VersionMajor"
strEntry4 = "VersionMinor"
strEntry5 = "EstimatedSize"

Set objReg = GetObject("winmgmts://" & strComputer & _
"/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys
WScript.Echo "Installed Applications" & VbCrLf
For Each strSubkey In arrSubkeys
  intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
   strEntry1a, strValue1)
  If intRet1 <> 0 Then
    objReg.GetStringValue HKLM, strKey & strSubkey, _
     strEntry1b, strValue1
  End If
  If strValue1 <> "" Then
    WScript.Echo VbCrLf & "Display Name: " & strValue1
  End If
  objReg.GetStringValue HKLM, strKey & strSubkey, _
   strEntry2, strValue2
  If strValue2 <> "" Then
    WScript.Echo "Install Date: " & strValue2
  End If
  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
   strEntry3, intValue3
  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
   strEntry4, intValue4
  If intValue3 <> "" Then
     WScript.Echo "Version: " & intValue3 & "." & intValue4
  End If
  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
   strEntry5, intValue5
  If intValue5 <> "" Then
    WScript.Echo "Estimated Size: " & Round(intValue5/1024, 3) & "
megabytes"
  End If
Next

Author
15 Jan 2009 10:12 PM
Richard Mueller [MVP]
Show quote Hide quote
"Bulldog Bill" <afsout32@nospam.nospam> wrote in message
news:%23fhYJp1dJHA.5540@TK2MSFTNGP05.phx.gbl...
>I downloaded the below script for listing all software loaded on a client
>station but when i run it undesr wscript or use the GUI I have to ok each
>and every capture, I am trying to get a list of what is on the station and
>get it output to a csv file if possible. I am new at all of this so any
>help at all would be appreciated. thanks in advance>
>
> Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
> strComputer = "."
> strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
> strEntry1a = "DisplayName"
> strEntry1b = "QuietDisplayName"
> strEntry2 = "InstallDate"
> strEntry3 = "VersionMajor"
> strEntry4 = "VersionMinor"
> strEntry5 = "EstimatedSize"
>
> Set objReg = GetObject("winmgmts://" & strComputer & _
> "/root/default:StdRegProv")
> objReg.EnumKey HKLM, strKey, arrSubkeys
> WScript.Echo "Installed Applications" & VbCrLf
> For Each strSubkey In arrSubkeys
>  intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, _
>   strEntry1a, strValue1)
>  If intRet1 <> 0 Then
>    objReg.GetStringValue HKLM, strKey & strSubkey, _
>     strEntry1b, strValue1
>  End If
>  If strValue1 <> "" Then
>    WScript.Echo VbCrLf & "Display Name: " & strValue1
>  End If
>  objReg.GetStringValue HKLM, strKey & strSubkey, _
>   strEntry2, strValue2
>  If strValue2 <> "" Then
>    WScript.Echo "Install Date: " & strValue2
>  End If
>  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
>   strEntry3, intValue3
>  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
>   strEntry4, intValue4
>  If intValue3 <> "" Then
>     WScript.Echo "Version: " & intValue3 & "." & intValue4
>  End If
>  objReg.GetDWORDValue HKLM, strKey & strSubkey, _
>   strEntry5, intValue5
>  If intValue5 <> "" Then
>    WScript.Echo "Estimated Size: " & Round(intValue5/1024, 3) & "
> megabytes"
>  End If
> Next
>

As with almost all administrative scripts, it is designed to be run at a
command prompt using the cscript host. You can redirect the output to a text
file. For example, if the script is saved in the file EnumSoftware.vbs, you
can run it at a command prompt with the command:

cscript //nologo EnumSoftware.vbs > report.txt

The //nologo optional parameter suppresses logo information. This assumes
the current directory is where the file EnumSoftware.vbs is saved, otherwise
you must include the full path to the file. The output is redirected to the
text file report.txt in the same directory. You can then read the file with
notepad (for example).

Modifying the script to write the output to a text file, or display the
results in message boxes, would make it more complicated. The program should
not be run with the wscript host program, or run by double-clicking the vbs
file in Windows Explorer.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--