View Full Version : File properties from DOS

Le Bodge
11th April 2001, 11:49
Do any of you good folks know whether there is a way of displaying a files properties from the DOS prompt?

I'm specifically after the File Version which you can get by Right Clicking the file in Explorer and selecting Version.


Le Bodge

11th April 2001, 14:09
ATTRIB /? will give you some details, not the version number though.

Ive never seen this done, but have a look around the MS knowledge base. Make sure you have a fast connection though http://forums.murc.ws/ubb/smile.gif


11th April 2001, 14:16
I don't think this will be possible, as I think this is a windows kind of information...


12th April 2001, 00:22
You'd have to find a prog made specifically for that task. DOS doesn't know or care what a .dll does or such. As long as it executes it's happy. The information your looking for is embedded in the file so if you used a hex editor or some-such you should be able to view it but as for a simple command you can run to easily display the ver number....that wouldn't come with DOS.

12th April 2001, 03:04
If you are running from a command prompt within Windows (and not from real DOS), here's one from Sysinternals:


It's not exactly what you're looking for, but it'll give you a list of *loaded* DLLs and their version numbers. You can run it from a command prompt and redirect the output to a text file, i.e. LISTDLLS > C:\LIST.TXT


12th April 2001, 13:27
It would require extensive knowledge of the PE executable format and the way Windows stores resources for a DOS program to correctly extract that information.

If by saying "DOS prompt" you mean a Windows Command Prompt and running Win32 console mode applications is an option, the job is greatly simplified and all you need is a few Win32 API calls with no knowledge necessary about exactly what is going on in the background.

All you need are basically the <a href="http://msdn.microsoft.com/library/psdk/winui/finstlib_5a79.htm">GetFileVersionInfoSize</a> and <a href="http://msdn.microsoft.com/library/psdk/winui/finstlib_9vu7.htm">GetFileVersionInfo</a> calls. The first takes a file name and a dword pointer, and returns the size of the version info resource if found.

Then you allocate enough memory to hold it and fill your buffer by calling GetFileVersionInfo.

From then on you could decode the data on your own (VERSIONINFO resources are basically just Unicode text blocks), or much more conveniently get the information you need through <a href="http://msdn.microsoft.com/library/psdk/winui/finstlib_4bad.htm">VerQueryInformation</a> calls.

The latter function's documentation on MSDN which I linked to even contains an example code snippet for extracting the FileDescription field, you should be able to adapt it to getting the FileVersion/ProductVersion fields instead in no time at all.

[This message has been edited by fds (edited 12 April 2001).]

[This message has been edited by fds (edited 12 April 2001).]

Le Bodge
12th April 2001, 13:39
Thank guys.

Yes, it would only be from a Windows command prompt.

I guess no one is aware of a program that already exists? It might be time to install that C compiler again.....

12th April 2001, 14:01
Here's the code:

#include "stdlib.h"
#include "windows.h"

int main(int argc, char* argv[])
char* buf;
DWORD len, dummy;
UINT fiilen;

if (argc!=2) {
printf("usage: %s filename\n", argv[0]); return 0xff;}

if ((len=GetFileVersionInfoSize(argv[1], &dummy)) &&
(buf=(char*)malloc(len)) &&
GetFileVersionInfo(argv[1], 0, len, buf) &&
VerQueryValue(buf, "\\", (LPVOID*)&pffi, &fiilen) &&
printf("%s\nFile Version: %d.%d.%d.%d\n"
"Product Version: %d.%d.%d.%d\n", argv[1],
return 0;
return 1;

and a <a href="http://web.matavnet.hu/fdsoft/verinfo/verinfo.exe">compiled executable</a>.

[This message has been edited by fds (edited 13 April 2001).]

12th April 2001, 15:20
Added to the FAQs http://forums.murc.ws/ubb/smile.gif

Le Bodge
12th April 2001, 17:26
Top Stuff!!!

Thank you very much!!

I didn't even have time to look for the C Compiler, let alone install it!


12th April 2001, 21:08
You can also use M$FT's utility (http://download.microsoft.com/download/ie4095/getvers/1/WIN98/en-us/GetVers.exe).