MSFN Forum: Checking for existing/prior versions - MSFN Forum

Jump to content



Unattended CD/DVD Guide Homepage · MSFN Forum Rules

Welcome to the Applications Installs forum. Make sure you read the forum rules before you start posting.

Links/Requests to warez and/or any illegal material (porn, cracks, serials, etc..) will not be tolerated. Discussion of circumventing WGA/activation/timebombs/keygens or any other illegal activity will also not be tolerated.

We try our best to keep this forum clean of illegal content. If you see any illegal activity use the "report" button you find in every post to report the specific post to the moderators. If you ignore any of the rules you will be banned without notice.

Read Forum Rules
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Checking for existing/prior versions and handling occurances through scripting... Rate Topic: -----

#1 User is offline   lamaslany 

  • Group: Members
  • Posts: 6
  • Joined: 14-October 05

Posted 10 April 2006 - 08:12 AM

Can anyone suggest some good reading material (or even provide examples!) of how to check whether an application is already installed and/or a previous version...

For example: Adobe Acrobat Reader. Is it possible to test whether the software is already installed and whether an earlier version is already installed?


Many thanks in advance for any assistance you can offer,

lamaslany


#2 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 10 April 2006 - 09:34 AM

Option Explicit
Dim ws, fs, strComputer, objWMIService, colSoftware, objSoftware
Set ws = WScript.CreateObject("WScript.Shell")
Set fs = CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery("Select * from Win32_Product")
For Each objSoftware in colSoftware
	If Left(objSoftware.Name, 12) = "Adobe Reader" Then
		WScript.Echo objSoftware.Name & " is installed."
		WScript.Echo "The installed version is: " & objSoftware.Version
	End If
Next


#3 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 11 April 2006 - 07:07 AM

Hey RogueSpear,

That VBS using WMI would not work at T-12 (Cmdlines.txt) , correct? :huh:

#4 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 11 April 2006 - 07:55 AM

Indeed it would not.

#5 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 11 April 2006 - 08:03 AM

I'll stick with enumerating the registry.

This is what I would use based on AutoIt3
$result = _InstalledVersion('Adobe Reader')
If Not @error Then MsgBox(0, 'Installed Version', $result)

Func _InstalledVersion($displayname)
	Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
	Local $i, $key_main, $key_result, $key_sub, $version
	For $i = 1 To 1000
		$key_sub = RegEnumKey($key_main, $i)
		If @error Then ExitLoop
		If RegRead($key_main & '\' & $key_sub, 'DisplayName') = $displayname Then
			$version = RegRead($key_main & '\' & $key_sub, 'DisplayVersion')
			If Not $version Or @error Then ContinueLoop
			Return $version
		EndIf
	Next
	SetError(1)
	Return
EndFunc


Edit:
Rude of me to forget, thanks for your reply, RogueSpear

This post has been edited by MHz: 11 April 2006 - 08:07 AM


#6 User is offline   RogueSpear 

  • OS: SimplyMEPIS
  • Group: Supreme Sponsor
  • Posts: 1,529
  • Joined: 18-September 04

Posted 11 April 2006 - 09:14 AM

@MHz, something to watch out for there is that the entry is not always exactly "Adobe Reader". I've seen it with a version number afterwards. That's why I keyed on the beginning of the string.

#7 User is offline   MHz 

  • SendToA3X v1.7
  • PipPipPipPipPipPipPip
  • Group: Members
  • Posts: 1,634
  • Joined: 02-August 04

Posted 11 April 2006 - 09:40 AM

View PostRogueSpear, on Apr 12 2006, 01:14 AM, said:

@MHz, something to watch out for there is that the entry is not always exactly "Adobe Reader". I've seen it with a version number afterwards. That's why I keyed on the beginning of the string.

The UDF I show relies on what you view in Add/Remove programs. If a program maker changes the name like changing pants, then real problems in identifing does come in. Yes, indeed entries can change as they sometimes add version number, so I will add in a StringLeft to handle the name without the rest. Thanks RogueSpear ;)

Add code here for comparison.
$result = _InstalledVersion('Adobe Reader')
If Not @error Then MsgBox(0, 'Installed Version', $result)

Func _InstalledVersion($displayname)
	Local $key_main = 'HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
	Local $i, $key_main, $key_result, $key_sub, $version, $size = StringLen($displayname)
	For $i = 1 To 1000
		$key_sub = RegEnumKey($key_main, $i)
		If @error Then ExitLoop
		If StringLeft(RegRead($key_main & '\' & $key_sub, 'DisplayName'), $size) = $displayname Then
			$version = RegRead($key_main & '\' & $key_sub, 'DisplayVersion')
			If Not $version Or @error Then ContinueLoop
			Return $version
		EndIf
	Next
	SetError(1)
	Return
EndFunc


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy