Announcement

Collapse
No announcement yet.

File properties from DOS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • File properties from DOS

    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.

    TIA

    Le Bodge

  • #2
    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

    Ali

    Comment


    • #3
      I don't think this will be possible, as I think this is a windows kind of information...

      AZ
      There's an Opera in my macbook.

      Comment


      • #4
        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.
        C:\DOS
        C:\DOS\RUN
        \RUN\DOS\RUN

        Comment


        • #5
          If you are running from a command prompt within Windows (and not from real DOS), here's one from Sysinternals:

          http://www.sysinternals.com/ntw2k/fr...listdlls.shtml

          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

          Frank

          Comment


          • #6
            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).]

            Comment


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

              Comment


              • #8
                Here's the code:

                <pre>
                #include "stdlib.h"
                #include "windows.h"

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

                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) &&
                fiilen)
                {
                printf("%s\nFile Version: %d.%d.%d.%d\n"
                "Product Version: %d.%d.%d.%d\n", argv[1],
                HIWORD(pffi->dwFileVersionMS),
                LOWORD(pffi->dwFileVersionMS),
                HIWORD(pffi->dwFileVersionLS),
                LOWORD(pffi->dwFileVersionLS),
                HIWORD(pffi->dwProductVersionMS),
                LOWORD(pffi->dwProductVersionMS),
                HIWORD(pffi->dwProductVersionLS),
                LOWORD(pffi->dwProductVersionLS));
                free(buf);
                return 0;
                }
                free(buf);
                return 1;
                }
                </pre>

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

                Comment


                • #9
                  Added to the FAQs
                  Jordâ„¢

                  Comment


                  • #10
                    Top Stuff!!!

                    Thank you very much!!

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

                    Cheers.

                    Comment


                    • #11
                      You can also use M$FT's utility.
                      <TABLE BGCOLOR=Red><TR><TD><Font-weight="+1"><font COLOR=Black>The world just changed, Sep. 11, 2001</font></Font-weight></TR></TD></TABLE>

                      Comment

                      Working...
                      X