Sign in to follow this  
Followers 0
4Eyes

Get ProductVersion of file from remote pc

11 posts in this topic

Folks,

I've been trying to find a method of getting the ProductVersion of an exe file on a remote pc.

I thought WMI and CIM_Datafile would be the shot for this but the 'Version' it gets is the FileVersion not ProductVersion. With Win32_Product I can get this info but there are 2 problems:

1) It takes a few seconds and that's a few seconds longer than I would like

2) I need to know the 'Product Name' and not all exe's have this

The native AutoIT functions don't give this info. Does anybody have a better idea?

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

stackoverflow is a great resource for questions like these

http://stackoverflow.com/questions/673233/wmi-installed-query-different-from-add-remove-programs-list

"I believe your syntax is using the Win32_Product Class in WMI. One cause is that this class only displays products installed using

Windows Installer. The uninstall registry key is your best bet."

"In order to build a more-or-less reliable list of applications that appear in the "Programs and Feautres" in the Control Panel, you

have to consider that not all applications were installed using MSI. WMI only provides the ones installed with MSI."

http://www.tech-archive.net/Archive/Windows/microsoft.public.windows.server.scripting/2005-05/msg00675.html

https://groups.google.com/forum/?hl=en&fromgroups#!msg/microsoft.public.windows.server.scripting/nllSH_jGSwI/f23vjBWd7D8J

The DisplayName property is what your after.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

Probably code already on the forum for this, GAFrost had some registry key enumerating code that worked for remote machines

Edited by rover

I see fascists...

Share this post


Link to post
Share on other sites

You can use the UDF _FileGetProperty that's linked in my signature to get that information from the file(s), it does work with UNC path names as well as local paths.

1 person likes this

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thanks for your replies guys.

@JScript, yes, that's part of what I do now. The technique that I'm trying to streamline copies an executable 'agent' file to the target pc, runs it and then reads some values from the remote pc registry. There are options to force updating of the values etc. This file copy action requires a mapped drive which brings into play all sorts of possible security issues. In the environment that I work in this is not an issue. Outside of this it well could be. Along with the security issues is that the drive mapping takes 5-10 seconds or sometimes much longer. The convenience of being able to collect the data is great and waiting for 1 pc is not so bad. Waiting for 200 or more is annoying to say the least. I was hoping to speed this up considerably with an alternative to my agent idea, but maybe it's not possible. Hmmm....

@Rover, I gathered that that was the case, IE only stuff 'installed' was listed. That method is slow and inflexible as I mentioned. Parsing the uninstall keys gives some interesting info, sometimes. For instance for the test case I'm looking at it gives 'DisplayName' and DisplayVersion, but not an install path so I can't be sure that the info discovered is unique to the program I'm looking for. Mileage varies with different programs.

@BrewManNH, after fighting with .Net Framework to get the test app installed I find that under XP the 'Product Version' is not returned by your UDF, so I'm still at square 1. Thank you for your assistance though.

This really is a bucket of worms. For instance, I have 2 versions of Network View installed. One has no 'Version' tab on its' file properties. The other does. NetPerSec's file version is correct, it's ProductVersion is not. It looks like there is no single answer to this.

I may have to at least temporarily settle for 'File version' instead of 'Product version'. It's not the end of the world I suppose. I'll keep working on it and see what I come with. Gary Frost did some work with GetFileVersionInfo but I dunno if it works over a LAN.

Share this post


Link to post
Share on other sites

In all of the program files I've checked, I haven't seen one where the File Version and the Product Version are different. What program are you checking where the 2 of them are different? Also, if XP doesn't return that information, how do you plan on getting it?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

NetPerSec shows a FileVersion of 1.1, but a ProduictVersion of 0,0,0,1. Afreecon.exe shows a FileVersion of 3.73.0.357, but a ProductVersion of 3.60. Audacity has no version tab. Several others on my work pc have no version tab. A more mainstream app... part of the latest Java package... javacpl.exe has a FileVersion of 10.5.0.05 while its ProductVersion is 7.0.50.5

The above was gathered by right clicking the exe file, choosing properties from the context menu, then the version tab.

FYI, the program that is causing me a particular issue is ClickView.exe. If you're interested, it can be downloaded from:

http://www.clickview.com.au/downloads/index.php At the moment I can't get WMI to read a version at all, yet the built-in FileGetVersion() works fine on my local pc.

How do I plan to get it? Well, it's not that XP doesn't return the info at all, it just doesn't return it to _FileGetProperty(). Hmmm... I can get the FileVersion via WMI as already stated. I could use a lookup table to translate FileVersions to ProductVersions but that's an ongoing stupidity. As already stated using WMI with Win32_Product gets the correct data but is slow and not universal. Quite frankly, at the moment I don't know. I have other issues to persue, so may get back to this after resolving them. As I said, this is part of an exercise to see if I can replace my agent program. Maybe I can't or maybe it's not going to be fast enough.

Edited by 4Eyes

Share this post


Link to post
Share on other sites

Bump.

Any suggestions?

Share this post


Link to post
Share on other sites

Please take a look at the _FileGetProperty UDF I linked to earlier, there was a bug in the code that was cutting off the information returned in the array so that not all of the known file properties were being returned in the array. BTW, if you had used the old version and you had done a search on "Product Version" it would have correctly returned the information, it was ONLY in the returned array that it was missing.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

BrewManNH,

That fixed it! Thanks for the update.

I was using the previous version, which I assume is the 'old' version you mentioned above, but looked in the array as displayed by _ArrayDisplay().

The current version in the post in your signature does the trick.

Edited by 4Eyes

Share this post


Link to post
Share on other sites

It was a strange bug, probably been there forever, just that no one needed the last few entries before more than likely. It only seemed to crop up on Windows XP because there are blank entries in some of the numbered spots, which was throwing off the count in the array. I hadn't even realized that they were missing until I looked for them by name instead of returning the full array.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0