Finding Excel.exe in a system using java

Hello,

I have to find the location of excel.exe file in any system.I figured out that I need to read the Windows registry.For this I got two approaches-

a) Using Preferences,(get the required class of registry by Reflection)--I am not aware of using this.

b) saving the registry values in a text file-Runtime.exec(regedit /e ... );

Doing this I am getting some special characters in the file and not sure how to read it.

Can anybody please let me know way of doing it or any other way of doing this?

(Ps: I am using Java1.5 and Windows XP)

[582 byte] By [Sruthi.ma] at [2007-11-26 16:48:24]
# 1
Add a dialog where the user can browse to the executable. Saves you a lot of hassle (different install locations, gazillion file iterations, windows registry access)
SurfManNLa at 2007-7-8 23:15:56 > top of Java-index,Java Essentials,Java Programming...
# 2

Add a dialog where the user can browse to the executable.

>>Cant do this.I have to do using a Java program,not Swing Application.

Saves you a lot of hassle (different install locations, gazillion file iterations, windows registry access)

>>I need a proper answer.If you can please give that.

Sruthi.ma at 2007-7-8 23:15:56 > top of Java-index,Java Essentials,Java Programming...
# 3

Well,

i can't give you an exact way to do this.

however you can find a "Key with String value" named "Path" under the below specified hive in windows registry for OFFICE 2003

KEY_NAME = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Excel\InstallRoot

as far registry checking is concerned java donot have inbuilt an API to manipulate or extract registry values.You might have to JNI for this.

http://forum.java.sun.com/thread.jspa?threadID=677755

checkout my post here to findout how to extract values from registry.

Hope this could be of some help.

REGARDS,

RaHuL

RahulSharnaa at 2007-7-8 23:15:56 > top of Java-index,Java Essentials,Java Programming...
# 4

Well,

i can't give you an exact way to do this.

however you can find a "Key with String value" named "Path" under the below specified hive in windows registry for OFFICE 2003

KEY_NAME = HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\11.0\Excel\InstallRoot

>>>Thanks Rahul, but I need to do it ina any version of Excel.So the path after Office might change;I cant just use the above key in all versions.

as far registry checking is concerned java donot have inbuilt an API to manipulate or extract registry values.You might have to JNI for this.

>>>Even I also thought like this ,until I read the following Post, where they said its possible.

http://forum.java.sun.com/thread.jspa?threadID=183505&messageID=721597

checkout my post here to findout how to extract values from registry.

>>> I read this Post.

Hope this could be of some help.

>>Thank you once again.

REGARDS,

Sruthi.

Sruthi.ma at 2007-7-8 23:15:56 > top of Java-index,Java Essentials,Java Programming...
# 5

Hello everybody ,

I found the way of reading registry though Java.I am executing a command line instruction to write details of registry to a file by the Runtime and then reading from the file;

Runtime.getRuntime().exec("regedit /e file name {youe key} ");

Now read the file,using any stream.

Sruthi.ma at 2007-7-8 23:15:56 > top of Java-index,Java Essentials,Java Programming...
# 6
Plz. send me the source cod eu used to extract the path of excel.exe from registry.Can i also extract all .exe files using ur source code. If u have some other option plz. suggest me. Thnx in advance. Its very urgent. Meghana
CuteGal_Pavana at 2007-7-8 23:15:56 > top of Java-index,Java Essentials,Java Programming...
# 7
I think native method will be a better option. You can have a native method which returns a string.
Basenta at 2007-7-8 23:15:56 > top of Java-index,Java Essentials,Java Programming...