Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you get a list of Installed Programs in VBS??

Status
Not open for further replies.

alistairpaul

Programmer
Apr 11, 2001
100
US
Does anyone know if there's a way to get the "Control Panel / Add/Remove Programs" list of programs using VBScript?

Also, the current version of windows and some HDD statistics (total space, free space) ??

Thanks for any hints/clues/direction!

Alistair
 
Below is my stripped-down "dirty" script for this purpose. You sure will have no problem in improving the user-interface and/or output to a nicely formatted file. It works for win9x. Because it appeals to RegObj.dll, it won't apply to win2000 without further work in adaptation.

'-------------listcpl_addrmvprg.vbs--------------------------------------

' Appeal to RegObj.dll that allows a script to access API functions via an object model.
' RegObj.dll is available from ms download if having a valid Visual Basic License
' There exist items which have to be screened out by DisplayName and UninstallString conjointly in order to be exact.

Dim WshShell, objReg, RootKey

Const Root = "HKEY_LOCAL_MACHINE"
Const skey = "\Software\Microsoft\Windows\CurrentVersion\Uninstall"
Const valname = "DisplayName"
Const valname2 = "UninstallString"
basekey = Root & skey

Set WshShell = WScript.CreateObject("WScript.Shell")
Set objReg = WScript.CreateObject("RegObj.Registry")
Set RootKey = objReg.RegKeyFromString("\"&basekey)

For Each oVal In Rootkey.Subkeys

testkey = Root & skey & "\" & oVal.Name & "\" & valname
testkey2 = Root & skey & "\" & oVal.Name & "\" & valname2

If KeyExists(testkey) And KeyExists(testkey2) Then
sregvalue=WshShell.RegRead(testkey)
'---- collect sregvalue here for output to file or better interface with user-----
WScript.Echo sregvalue
'---- temporary getby solution only -----------------------------------------
End If
Next

Function KeyExists(tkey)
Dim tmpkey
On Error Resume Next
tmpkey = WshShell.RegRead(tkey)
If Err <> 0 Then
KeyExists = False
Else
KeyExists = True
End If
On Error GoTo 0
End Function

'-----End------listcpl_addrmvprg.vbs------------------------------------------

Note again that you have to have RegObj.dll registered to your system beforehand.
Thanks for posting the question.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top