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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for installed programs

Status
Not open for further replies.

mospa

Technical User
Aug 4, 2006
11
GB
I'm new to scripting and want to create a script which will check if 4 or 5 programs are installed on client machines or not. Would the best of doing this be to check registry entries?

So far I have:
Code:
Dim WSHShell 
Dim objAdr 
On error resume next 
Set WSHShell = WScript.CreateObject("WScript.Shell") 
test = wshshell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\...") 
If error.number > 0 Then 
msgbox "not installed" 
else msgbox "installed" 
end if 
wscript.echo test

Which doesn't seem to work. Is the "If error.number > 0 Then " correct?

All help welcome.
 
Has anyone written a script to perform the same or a similar task?
 
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"

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
Next
 
difficult to say what is the best way to check if a particular application is installed, unless you have a rigid standard of way of installing applications (i.e. they are all packaged to msi, they are all installed with a 'wrapper',,,etc etc) then i would say it would all depend on the application in question, whatever you define an 'application' to be
 
Do the programs list themselves in Control Panel, Add/Remove Programs? If so then the easiest thing to do is enumerate the Uninstall Registry Folder.



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top