Open File Properties Dialog Box from Command Line

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:

http://www.freevbcode.com/ShowCode.asp?ID=445

Any help appreciated.
harlanhughAsked:
Who is Participating?
 
nonubikCommented:
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.
0
 
nonubikCommented:
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);
   }
0
 
harlanhughAuthor Commented:
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++?
0
 
harlanhughAuthor Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.