what is the easyest way to run a .bat .com or .reg file from java?

long story :

I useally use windowskey+R and type a command in and that brings up the program or folder i want. I was getting sick of having to go in the registry every time i wanted to add a command so i made a java program that pops up with a window that allows you to put a command and then a path and it makes a .reg file that you double click on and its adds the new run command. well i would like to have the .reg file automaticlly run without haveing to click on it soooooooooooo..............

short story:

whats the easyest and smallest amount of code to open a .bat .com or .reg file?

ps if anyone wants this program say so and ill post it on the board. i find it pretty usful. oh but if you edit any of it and make it better i want a copy back ; )

Message was edited by:

xtheblack9x

[835 byte] By [xtheblack9xa] at [2007-11-26 13:49:11]
# 1
Runtime.exec() can run it, but you'd better read this first: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html%
duffymoa at 2007-7-8 1:25:33 > top of Java-index,Java Essentials,New To Java...
# 2
i think this may be a little over my head. is there something that explains it ground up? more on how to do it then the right way to do it (don't get me wrong i need to read the right way to do it to). but im kinda a begianer programer :(
xtheblack9xa at 2007-7-8 1:25:33 > top of Java-index,Java Essentials,New To Java...
# 3

There's this great video clip where you're looking at one of those "Press to Cross" buttons, but this one has an extra button labelled "Press to Blow up Building". You watch several pedestrians go by, each on using the Cross button without really looking at it. Finally, someone accidentally presses the other button and the office building across the street blows up. Startled, the pedestrian looks at the building, then at the label on the button he pushed. He looks around guiltily, then walks away quickly.

I can't imagine what brought it to mind, but I love that video.

uncle_alicea at 2007-7-8 1:25:33 > top of Java-index,Java Essentials,New To Java...
# 4
ha ha ha alright ill read it and try to figure out. Like i said im a begianer programer so im a little slow :(
xtheblack9xa at 2007-7-8 1:25:33 > top of Java-index,Java Essentials,New To Java...
# 5
> i think this may be a little over my head. is there> something that explains it ground up? This is the ground up view.Have you tried reading the javadocs, now that I've steered you in the right direction with Runtime.exec?%
duffymoa at 2007-7-8 1:25:33 > top of Java-index,Java Essentials,New To Java...
# 6

Seriously, creating and running .reg files programmatically is insanely risky. One little bug or malformed input could potentially render your computer totally unusable. If you can find a way to do what you want without editing the Registry directly, you should do it that way. For instance, if you want to associate a certain file type with a certain program, you can use the assoc command. It's an internal command, not a stand-alone executable, so you would have to use cmd.exe to run it. There are some examples of that approach in the article duffymo inked to.

uncle_alicea at 2007-7-8 1:25:33 > top of Java-index,Java Essentials,New To Java...