Open File Properties Dialog Box from Command Line

Posted on 2005-04-15
Last Modified: 2008-01-09
I am trying to open the file properties dialog for a file/folder using a command line syntax, similar to how rundll32 can be used to open a file:

rundll32 SHELL32.DLL,ShellExec_RunDLL %1

Only instead of opening the file, I want to see the dialog with the size, sharing info, etcetera.

I found an article describes how to do this using VB, but I want to do something from a command line so I can execute it easily from Java...

Here is the VB article:

Any help appreciated.
Question by:harlanhugh
    LVL 16

    Expert Comment

    You could use directly the ShellExecute function from java:

    public void launchProperties(String file) throws Exception
          int retval;
          retval = Shell32.ShellExecute(0,"properties",file,null,null,wins.SW_SHOWNORMAL);

          if (retval <= 32)
             User32.MessageBox(0,"File not found","Alert!",winm.MB_OK);
    LVL 16

    Expert Comment


    Author Comment

    What is the Shell32 package? I hadn't seen that before...

    How about writing a C++ dll or even .exe I could call from Java via JNI or command line?

    Anyone with some VB experience care to convert the sample code to C++?
    LVL 16

    Accepted Solution

    Here's the C++ function:

    #include <shellapi.h>

    void ShowProperties(const TCHAR *szFileName)
      int iRet = ShellExecute(0, "properties", szFileName, 0, 0, SW_SHOWNORMAL);
      if(iRet <= 32)
        MessageBox(0, "FileNotFound", "Alert!", MB_OK);

    You can make a regular DLL, export 'ShowProperties' function and link against shell32.lib.

    Author Comment

    I got your code to work, but the properties dialog refuses to display...

    I tried it a many different ways (ShellExecute, ShellExecuteEx, with an HWND, without, with fMask, without, etcetera), but I couldn't get properties to display... the open, and print, verbs work fine, just not properties?!

    I am going to quit now on this one and rewrite the functionality in Java. Thanks anyhow.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    A short article about a problem I had getting the GPS LocationListener working.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now