Link to home
Start Free TrialLog in
Avatar of Shankar3003
Shankar3003

asked on

SCRIPT TO CHECK ADOBE VERSION 8.1.3

Hi,

     I require some help to find out how many users are using adobe version 8.1.3. Is there a script which i can use for this ? I can deploy this script at GPO logon script so that when users logon the script will tell if there is version 8.1.3 installed. Please advice ,thank you.
Avatar of bluntTony
bluntTony
Flag of United Kingdom of Great Britain and Northern Ireland image

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

'Set variable required values
strLookFor = "MSXML 6.0 Parser (KB933579)"
strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "DisplayVersion"
strFolderName = "C:\Compatws_applied"

'Get all registry subkeys of strKey, loop through all 'DisplayName' keys and check if a match for strLookFor is found....
Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys
For Each strSubkey In arrSubkeys ' GO THROUGH ALL SUBKEYS
      objReg.GetStringValue(HKLM, strKey & strSubkey, strEntry1a, strValue1) ' READ IN DisplayName as strValue1
      If strValue1 = strLookFor Then ' If the name is a match...
          objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1b, dispVer ' Read in DisplayVersion as dispVer
          WScript.Echo(dispVer) ' Echo display version
      End If        
Next
The above vbscript enumerates all the subkeys in the registry key SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\.

It checks the DisplayName value, if it matches the given string, then it returns the DisplayVersion value.

The above example looks for 'MSXML 6.0 Parser (KB933579)' in DisplayName and then returns the corresponding DisplayVersion. Where I have echoed the version number, you can do a test on the required string and then do whatever.

Check the registry keys on a machine where the software is installed, find the right GUID for the software and make a note of the DisplayName value, then test for it in the above script.

It's a bit rough but I've used it to good effect myself before :)

HTH
Oh, and you can delete the line:

strFolderName = "C:\Compatws_applied"

(that was a remnant from my original script which I pasted in by mistake!)
Avatar of Shankar3003
Shankar3003

ASKER

I get an error while running the script.


adobe.jpg
Apologies! Some erroneouos brackets have been removed now:

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE

'Set variable required values
strLookFor = "MSXML 6.0 Parser (KB933579)"
strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "DisplayVersion"

'Get all registry subkeys of strKey, loop through all 'DisplayName' keys and check if a match for strLookFor is found....
Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys
For Each strSubkey In arrSubkeys ' GO THROUGH ALL SUBKEYS
      objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1a, strValue1  ' READ IN DisplayName as strValue1
      If strValue1 = strLookFor Then ' If the name is a match...
          objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1b, dispVer ' Read in DisplayVersion as dispVer
          WScript.Echo(dispVer) ' Echo display version
      End If        
Next
Hi,
    Can i enquire where can i have the option to set the path to display the results?
The script as it is, should display the version number, but only if the particular DisplayName string is found (specified in the 'strLookFor' variable).

What exactly do you want the script to do when it finds Adobe installed?

For example, do you want it to send an email when it finds Adobe installed, telling you the user, machine name and the version of Adobe? Do you want it to write to a text file on a shared drive (bearing in mind if you have a number of users logging in at the same time it might not be a good idea to have them trying to write to the same file).
Out of interest, what Adobe software is it? Adobe Reader? Adobe Acrobat?
i will like the script to be complied in a text file as there maybe over 1000 users which need to be searched. The ones with adobe installed will be recorded as well as those without the adobe installed. How can i do so?
See the attached snippet.

In this example I have changed to look for Adobe reader versions. It will write to a text file in C:\examplelog.txt. If Adobe Reader is installed, then it gives the machine, user and version number. If not installed, it gives the machine and user. Change the path to a network share (you can use a UNC) and ensure users have write access.

This script assumes that the text file exists, so will not work unless you've already created the text file. Also, if you have 1000+ users logging on around the same time, you are likely to get locking errors. IMPORTANT!!! - I have turned error handling on so the script will not throw an error, but it will continue to try to open the text file until it is not locked by anyone else. This is done with the DO/LOOP part of the script. If you are not comfortable with this I would remove the entire DO/LOOP. If you do remove , if the user is locked out, the script will continue but will fail to write to the file.

HTH
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
Const ForAppend = 8
 
On Error Resume Next
 
'Set variable required values
strLookFor = "Adobe Reader"
strComputer = "."
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "DisplayVersion"
strTxtFile = "C:\examplelog.txt"
 
Set objNetwork = CreateObject("WScript.Network")
currUser = objNetwork.UserName
currMachine = objNetwork.ComputerName
 
'Get all registry subkeys of strKey, loop through all 'DisplayName' keys and check if a match for strLookFor is found....
Set objReg = GetObject("winmgmts://" & strComputer & "/root/default:StdRegProv")
objReg.EnumKey HKLM, strKey, arrSubkeys
For Each strSubkey In arrSubkeys ' GO THROUGH ALL SUBKEYS
	objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1a, strValue1 ' READ IN DisplayName as strValue1
	If Left(strValue1, Len(strLookFor)) = strLookFor Then ' If the name is a match...
    	objReg.GetStringValue HKLM, strKey & strSubkey, strEntry1b, dispVer ' Read in DisplayVersion as dispVer
    	boolFound = True
       	Exit For
	End If        
Next
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile(strTxtFile, ForAppend, True) 
 
'Continue to try to open the file until it isn't locked by someone else...
Do Until Err.Number <> 70
	Err.Clear
	Set objTextFile = objFSO.OpenTextFile(strTxtFile, ForAppend, True)
	WScript.Echo("In")
Loop
 
If boolFound = True Then
	txtMessage = "Machine: " & currMachine & ", current user: " & currUser & ", has " & strLookFor & " version " & dispVer & " & installed!"
Else
	txtMessage = "Machine: " & currMachine & ", current user: " & currUser & ", does not have " & strLookFor & " installed!"
End If
 
objTextFile.WriteLine(txtMessage)
objTextFile.Close
 
Set objNetwork = Nothing
Set objFSO = Nothing

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of bluntTony
bluntTony
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hope it helps you out. Just remember that if using for a large number of users that you become familiar with the code and it's implications.

Another way to do this could be to query AD for computer objects in OU's, then query each computer's registry remotely using WMI.