Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Open File Properties Dialog Box from Command Line

Posted on 2005-04-15
Medium Priority
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
  • 3
  • 2
LVL 16

Expert Comment

ID: 13797840
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

ID: 13797860

Author Comment

ID: 13801054
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

nonubik earned 750 total points
ID: 13803980
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

ID: 13812553
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Simple Linear Regression

578 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