Ask a Question

Identify if product is installed

SOLVED
MulgraveTester
Frequent Contributor

Identify if product is installed

My tested program now comes in 3 variants so I need to load different data depending on the variant of the product installed.

Only one variant can be installed at a time, so I want to see which variant is installed before stating my test.

Using VBScript how can I get the name of installed programs and test which of my three variants is installed?

1 ACCEPTED SOLUTION

Accepted Solutions
Colin_McCrae
Community Hero

Re: Identify if product is installed

Is it a 64 bit machine? (And a 64 bit install you're searching for)

 

Just wondering if:

 

("Select * from Win32_Product") 

 

...  is not catching a 64 bit installs?

 

Here's an alternative from MS that uses the registry.

 

https://gallery.technet.microsoft.com/scriptcenter/8035d5a9-dc92-436d-a60c-67d381da15a3

View solution in original post

4 REPLIES 4
Colin_McCrae
Community Hero

Re: Identify if product is installed

It's an old article, but looks like it should be useful for what you want ....

 

http://www.symantec.com/connect/blogs/check-installed-applications-vb-script

 

(PS ... was the first result in a google search for "vbscript check installed programs" Smiley Wink )

MulgraveTester
Frequent Contributor

Re: Identify if product is installed

I've written this

 

sub checkInstall
  Set WmiService = GetObject ("WinMgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

  Set colSoftware = WmiService.ExecQuery ("Select * from Win32_Product") 

  for each softwareItem in colSoftware
    log.message("Name (" & softwareItem.name & ") and Version (" & softwareItem.version & ") and Vendor (" & softwareItem.vendor & ")")
  next

end sub

 

which lists all software installed by a Windows installer but it does not list all products installed and the product I am testing in particular. How do I get a complete list of software installed - as shown in Programs and Features?

Colin_McCrae
Community Hero

Re: Identify if product is installed

Is it a 64 bit machine? (And a 64 bit install you're searching for)

 

Just wondering if:

 

("Select * from Win32_Product") 

 

...  is not catching a 64 bit installs?

 

Here's an alternative from MS that uses the registry.

 

https://gallery.technet.microsoft.com/scriptcenter/8035d5a9-dc92-436d-a60c-67d381da15a3

View solution in original post

MulgraveTester
Frequent Contributor

Re: Identify if product is installed

Thanks Colin, The registry search solution worked for me. Here is my simplified version (Where you see the emoticon it should be ":" then "S". I couldn't see how to turn off emoticons.)

 

sub checkInstallReg
  Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
  strComputer = "."
  strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
 
  Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
  objReg.EnumKey HKLM, strKey, arrSubkeys

  For Each strSubkey In arrSubkeys
    objReg.GetStringValue HKLM, strKey & strSubkey, "DisplayName", strSoftwareName
    objReg.GetStringValue HKLM, strKey & strSubkey, "InstallDate", strInstalledDate
    objReg.GetStringValue HKLM, strKey & strSubkey, "DisplayVersion", strDisplayVersion   
    log.Message("Name (" & strSoftwareName & ") Version (" & strDisplayVersion & ") Installed on (" & strInstalledDate & ")")  
  Next

end sub

cancel
Showing results for 
Search instead for 
Did you mean: