I would like to get a list like below:
a.dll 1.0.0
b.dll 1.0.1
c.dll 1.0.2
I would like to get a list like below:
a.dll 1.0.0
b.dll 1.0.1
c.dll 1.0.2
I have been using the following JScript code for this task for a long time:
var args = WScript.Arguments;
if (1 != args.Length)
{
print ("usage: fver <filename>");
WScript.Quit(1);
}
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fldr = fso.GetFolder(args(0));
var files = new Enumerator(fldr.Files);
for (; !files.atEnd(); files.moveNext())
{
var f = files.item();
var ver = getver(f.Name);
if (ver)
{
print(f.Name + "\t" + ver);
}
}
function getver(filename)
{
try
{
return fso.GetFileVersion(filename);
}
catch (ex)
{
print("#error: " + ex.description)
}
}
function print (msg)
{
var cout = WScript.StdOut;
cout.WriteLine(msg);
}
Just give it a handy filename, my one is called fver.js and put it to a folder that is listed in your %PATH% environment variable. Then you can type in the following command:
C:\your\folder\>cscript fver.js .
or, if you want to save typing, you can tell the ms script host that you want to use the console script runtime in the future once and for all:
C:\>cscript /h:cscript /nologo /s
The /s switch will save your preference and the next time you execute a script (.js or .vbs), cscript.exe will be called:
C:\your\folder\>fver.js .
The code has dependecy for the COM object Scripting.FileSystemObject, it is a part of microsoft scripting runtime, and ships with all windows versions now.