Before you read this, please don't say how I could make this better, I've thought of it, or because of the circumstances, it's not possible.

I'm having a problem where when I input a command into the Runtime class's exec function, it doesn't run. When I try the exact same function in command line (the problem seems to be happening on windows only) it works without hesitation.

My problem results from the following code:

Runtime.getRuntime().exec("START "+(new File(files[i]).getAbsolutePath()+".lnk"));

A few notes:
A) files is a string containing a path to a file. This file is a .lnk file. This is predetermined.
B) "START" is a windows command line command. This seems to be my only option for launching programs like .exe, .bat, or .lnk.
C) I add ".lnk" to the end of the file path because it has been determined that the path doesn't have it on there already.
D) The file is correctly formatted.

If you want to have me use ProcessBuilder, I've tried it, and so has google, and it doesn't do any different than Runtime does.


Create the full command as a String before calling the exec method and print it out so you can see if it is correct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.