Sponsored Link •
|
Advertisement
|
Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.
Message:
Minor correction: In the previous post, I used <path> below in the string for Runtime.exec() and it was interpreted as a (non-existent) HTML tag and disappeared, so I just changed it to [path], below. > But how do I get my program to change the file associations? Because I would want to change the file associations on customers' computers so that when they double click on my JAR files, they open up like an exe. Ah ha. You want to do it programmatically. Well here is one relatively simple way: First, create a text file,
(You could change the %1 to %L if there are short/long filename problems. Also, although you see both '\' and '\\' used above, rest assured it is correct.) Now all you have to do is import that reg file; if you do a You can dynamically create the reg file in the temp directory and also delete it when you are finished, by the way. Of course, there are a myriad of other methods, such as doing it with a little Windows Script Host script (JScript, or VBScript (ick!)), using an INF file (if you don't already know how, this is complicated and ugly, too), writing a Java Native Method for registry manipulation (overkill, unless you need it for other purposes) or writing a little C/C++ tool to do it (kind of redundant, since that is exactly what RegEdit is) and so on.
Replies: |
Sponsored Links
|