mIRC Homepage

Yet another COM Object newbie question..

Posted By: VIO_Maverick

Yet another COM Object newbie question.. - 09/08/04 03:19 AM

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..

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
Posted By: Online

Re: Yet another COM Object newbie question.. - 11/08/04 12:53 AM

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

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

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.
Posted By: VIO_Maverick

Re: Yet another COM Object newbie question.. - 11/08/04 01:07 PM

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
Posted By: Online

Re: Yet another COM Object newbie question.. - 12/08/04 04:46 AM

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:
Posted By: VIO_Maverick

Re: Yet another COM Object newbie question.. - 13/08/04 06:13 PM

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
© 2022 mIRC Discussion Forums