1

I want to write a Java code, to get the description of any file located on a Windows server. The Description has to be the same as mentioned in the file after right clicking on it and then clicking on Properties.

For example, following is the file: C:\Program Files\Google\Chrome\Application\chrome.exe Right click on it, and click on Properties. The description is "Google Chrome".

Please help.

UPDATED:

Even if someone can give me a method to derive the data of the "Description" field shown in the Windows Task Manager for a particular ProcessID, it will help me.

  • I think this will help you: http://stackoverflow.com/questions/10824027/get-the-metadata-of-a-file –  Feb 16 '15 at 10:56
  • Some more inputs from here : http://stackoverflow.com/questions/4096973/reading-windows-file-summary-properties-title-subject-author-in-java – TJ- Feb 16 '15 at 10:56
  • What is your JDK version? – Beri Feb 16 '15 at 11:07
  • @Beri my JDK version is 1.6 – Abhijeet Kharkar Feb 16 '15 at 13:13
  • @AbhijeetKharkar If only you could upgrade to JDK7 you could use benefits of java.nio.file.Files util, sources: http://www.javabeat.net/obtaining-and-modifying-the-metadata-of-the-files-in-java-7-nio-2/. But I have never used thm for reading file descriptions, those are not standard file data. – Beri Feb 16 '15 at 13:22
  • @Beri i have updated my question just now. If you may help me even with that, it would solve my problem. – Abhijeet Kharkar Feb 16 '15 at 13:25
  • @AbhijeetKharkar in that you could use this: http://stackoverflow.com/questions/54686/how-to-get-a-list-of-current-open-windows-process-with-java . Name of process can be added when you start it. It is not directly connected with file itself, in linux at least. I don't know much about windows. – Beri Feb 16 '15 at 13:37
  • @Beri Thanks anyways. I am not able to find any link to achieve what I have mentioned in the question. I have began believing that the thing which I want is not actually possible. – Abhijeet Kharkar Feb 16 '15 at 13:52
  • @AbhijeetKharkar it might be easy to do in linux enviroment, as you have ready command line for that. But windows is not so develop friendly :) Good luxk with your quest for answers:) – Beri Feb 16 '15 at 13:54

1 Answers1

0

check this - it will return the right-click-> details of a file . You can start it from java like this

try
{
    String line=null;
    String filePath="\"YOUR FILE PATH\"";
    Process p = Runtime.getRuntime().exec("toolTipInfo.bat "+filePath);
    String processDesc="";
    BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));       
    while ((line = input.readLine()) != null)
    {
        if(line.contains("File description:"))
            processDesc=line.split(":")[1].trim();
    }
    input.close();
}
catch(IOException e)
{

}
npocmaka
  • 55,367
  • 18
  • 148
  • 187