mIRC Home    About    Download    Register    News    Help

Print Thread
Yet another COM Object newbie question.. #93371 09/08/04 03:19 AM
Joined: Aug 2004
Posts: 6
V
VIO_Maverick Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Aug 2004
Posts: 6
I have just recently started scripting, I have now hit a wall, can someone help me with retreving version information from an exe file?
Or better yet, give me a way to do it wink

I want the information that shows up when you right click and go to the version tab in windows..

ex:
Version language : English (United States)
CompanyName : mIRC Co. Ltd.
FileDescription : mIRC
FileVersion : 6.16
InternalName : mIRC
LegalCopyright : Copyright © 1995-2004 mIRC Co. Ltd.
LegalTrademarks : mIRC® is a Registered Trademark of mIRC Co. Ltd.
OriginalFilename : mirc.exe
ProductName : mIRC
ProductVersion : 6.16

Re: Yet another COM Object newbie question.. #93372 11/08/04 12:53 AM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
A mIRC DLL would be great for this task, but I'm not aware of any.

The simplest way is to use FSO's GetFileVersion() method. It's relatively fast, but it only gives the file version number.

alias GetFileVersion {
  • [color:purple]; Usage: $GetFileVersion(filename)

    .comopen oFSO Scripting.FileSystemObject
    !.echo -q $com(oFSO, GetFileVersion, 1, bstr, $1)
    var %ver = $com(oFSO).result
    .comclose oFSO
    return %ver
}[/color]

If the rest of the information is important to you, copy Microsoft's FileVer.exe to your mIRC folder and call it as follows:

alias FileVer.exe {
  • [color:purple]; Usage: $FileVer.exe(filename, items)
    ;
    ; Possible items:
    ; CompanyName FileDescription InternalName
    ; OriginalFilenam ProductName ProductVersion
    ; FileVersion LegalCopyright LegalTrademarks

    .comopen oShell WScript.Shell
    .comclose oShell $com(oShell, Run, 1, bstr, % $+ COMSPEC% /c $&
    filever.exe /v $1 > $mircdirver.txt, uint, 0, bool, true)
    alias _fver $eval(set -u %fver $instok(%fver, $gettok($1, 2, 9), 0, 58),0)
    filter -fkg ver.txt _fver /^\t(?: $replace($2-,$chr(32),|) )/xi
    .remove ver.txt
    alias _fver
    return %fver
}[/color]

Of course, it's always possible to examine the file with mIRC's binary commands, but that's too much trouble for an ordinary script. visionz has done that in his Resource Viewer, but it's still beyond my knowledge. Sorry.

Re: Yet another COM Object newbie question.. #93373 11/08/04 01:07 PM
Joined: Aug 2004
Posts: 6
V
VIO_Maverick Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Aug 2004
Posts: 6
Alright man, Thanks for the help.
I gota get ready for work now or I'll be late :P

I'll try it when i get home.

BTW, mostly what i was wanting at this point, was ProductName and FileVersion.
Anyways, gota run..

Thanks again... laugh

Re: Yet another COM Object newbie question.. #93374 12/08/04 04:46 AM
Joined: Dec 2002
Posts: 1,922
O
Online Offline
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
With kind help from visionz I was able to come up with an independent, purely scripted version. It's not as fast as a DLL, but not terribly slow. Examples,

//echo - $VerInfo([color:purple]mirc.exe)
//echo - $VerInfo(mirc.exe).ProductName
//echo - $VerInfo(mirc.exe).FileVersion[/color]

These resources helped me to understand the Portable Executable file format, and therefore to make the script:

Re: Yet another COM Object newbie question.. #93375 13/08/04 06:13 PM
Joined: Aug 2004
Posts: 6
V
VIO_Maverick Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
V
Joined: Aug 2004
Posts: 6
Thanks for all of the help grin

I decided to use the filever.exe, works good and it doesn't increase my script size by a lot

btw: I'm not sure if it can be done, but I think it can be recalled via Shell.Application because the call feature is an extention of explorer, its in Windows\System32\shell32.dll as SHGetFileInfo, It may be DLLGetVersion........Not Sure

Last edited by VIO_Maverick; 13/08/04 06:18 PM.