Sign in to follow this  
Followers 0
tazdev

Software Inventory

9 posts in this topic

This will do a quick and dirty software inventory on the PC you run it on. It basically searches the registry's uninstall section and reports all the stuff there. Exports it to at Text file on the root of c: named after the PC's name-programs.txt

(Thanks Larry)

#cs
Routine to get a listing of all the software uninstallable from Add/Remove Programs
It works well as an inventory of sorts for the PC
Exports it to a text file on the root of C:\ named after the PC you are on.

Tazdev 06-28-05 tazdev@gmail.com
Version 1.00
#ce

$ver = "1.00"
$y = 1
$k = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
$fn = ("c:\" & @ComputerName & "-programs.txt")
If FileExists( $fn ) then
    FileDelete( $fn )
EndIf
$f = FileOpen( $fn, 1)
; Check if file opened for writing OK
If $f = -1 Then
    Exit
EndIf
Do
    $a = RegEnumKey($k, $y);gets the key
    $as = Stringleft($a, 1)
    $sv = RegRead($k & "\" & $a, "DisplayVersion")
    $sn = RegRead($k & "\" & $a , "DisplayName")
    If $as = "{" then
        $y = $y + 1
        $a2 = ($sn & " - " & $sv)
        FileWrite($f, $y & " - App: " & $a2 & @CRLF)
    Else
        If $a = "" Then
            FileWrite($f, @CRLF)
            $y = $y + 1
        Else
            FileWrite($f, $y & " - App: " & $a & " - " & $sv & @CRLF)
            $y = $y + 1
        EndIf
    EndIf
Until $a = ""
FileClose($f)

Share this post


Link to post
Share on other sites



This will do a quick and dirty software inventory on the PC you run it on. It basically searches the registry's uninstall section and reports all the stuff there. Exports it to at Text file on the root of c: named after the PC's name-programs.txt

(Thanks Larry)

Sweet I was just wanting to learn how to do something like this. I will give it a go.

Thanks,

Share this post


Link to post
Share on other sites

tazdev, nice simple script. Work perfectly.. :evil:

Cheers.. :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

A more effective method consists in using WSH scripting ,loading WindowsInstaller.Installer object.

My working scripts : ( save it as yourscript.vbs ) It needs a argument : the file name in witch you want to store installation informations.

Const cReadOnly = 0
Const cForWriting = 2
Const cPID_WORDCOUNT = 15
Const cHKEY_CLASSES_ROOT = &H80000000
Const iProdLen = 28
const SEP=";"

'------------------------------------
' Network object
'------------------------------------
Set WshNetwork = Wscript.CreateObject("Wscript.Network")


On Error resume next
Set fso = CreateObject("Scripting.FileSystemObject")
set FICLOG = fso.OpenTextFile(WScript.Arguments(0),2,True)
Set msi = CreateObject("WindowsInstaller.Installer")

If Err.Number = 0 Then
'------------------------------------
' File writing object
'------------------------------------
    Set fso = CreateObject("Scripting.FileSystemObject")
    set FICLOG = fso.OpenTextFile(WScript.Arguments(0),2,True)

'Write computername to output string
    FICLOG.Writeline "# PC name :  " & Wshnetwork.computername
    FICLOG.Writeline "# installer Version : " & msi.version

'Iterate through all installed PRODUCTS based on Windows Installer
    For Each prod In msi.Products
'Gather information from ProductInfo
'
        LIGNE=msi.ProductInfo(prod, "ProductName") & SEP
        LIGNE = LIGNE &  msi.ProductInfo(prod, "PackageName") & SEP
        LIGNE = LIGNE &  msi.ProductInfo(prod, "VersionString") & SEP
        LIGNE = LIGNE &  msi.ProductInfo(prod, "InstallSource") & SEP
        LIGNE = LIGNE &  msi.ProductInfo(prod, "LocalPackage") & SEP

' Per User / Par Computer
        If msi.ProductInfo(prod, "AssignmentType") = "0" Then
            LIGNE = LIGNE & "PU" & SEP
            Else
            LIGNE = LIGNE & "PC" & SEP
            End If

        LIGNE = LIGNE &  msi.ProductInfo(prod, "PackageCode") & SEP
        FICLOG.writeline LIGNE
    Next
else
    FICLOG.writeline "# Error activating windowsinstaller"
End If
FICLOG.writeline "# END"
'Clean up objects
Set msi = Nothing
FICLOG.Close

then call the WSH script from autoit like this:

$MSIFILEINST=@TempDir & "MSINST_" & @ComputerName & ".txt"
$RETCOD=RunWait ( "wscript.exe yourscript.vbs " & $MSIFILEINST) 

$FILEDESC=fileopen ( $MSIFILEINST,0)
; reread file ...
etc....
Edited by sksbir

Share this post


Link to post
Share on other sites

Hi,

very nice. Similar to this : Installed Software

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Hi,

very nice. Similar to this : Installed Software

So long,

Mega

not similar : scripts from this thread use registry : the advantage is that you don't need any resource out from autoit.

The drawback is that this scripts don't care about programs wich are installed with a per user strategy. You have to check in HKCU too if you want a full inventory.

@gene : this is the same thread... :P

Share this post


Link to post
Share on other sites

not similar : scripts from this thread use registry : the advantage is that you don't need any resource out from autoit.

The drawback is that this scripts don't care about programs wich are installed with a per user strategy. You have to check in HKCU too if you want a full inventory.

@gene : this is the same thread... :P

:"> Wry/sheepish grin, It wuz late, sorry.

Gene


[font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0