java.io.IOException: Cannot run program ""D:\prog": CreateProcess error=193, %1 ???Ч?? Win32 ??ó
Caused by: java.io.IOException: CreateProcess error=193, %1 ???Ч?? Win32 ??ó
at java.lang.ProcessImpl.create(Native Method)
... 4 more
Ah, it only works if you put the quotes around the path parts that contain spaces. I tried quoting the entire path, as one would expect.
So the rundll32 solution is easier - it does the same* but only requires the quotes around the entire path, not each part.
* The main differences I found are:
1) rundll32 does not show an "open with" window if there is no program associated with the file
2) rundll32 does not show an error if the file does not exist
Edit: tried it some more, and if the file path contains spaces, "cmd /c start" needs quotes around everything after the drive specification. For instance C:\\\"prog file\\090422.xls\"". So if you use getAbsolutePath(), strip of the drive part, add quotes and add the drive part again, you're safe ;)
I've one clarifications to seek. "/c" in the argument tells cmd to execute anything that comes after it. Can we have more than 2 commands to execute using the above exec method ? if yes, then how do we do that ?
Bartek Myszkowski wrote:I know You've solved the problem but.. isn't this easier:result is the same and You don't have to "play" with cmd here...
It is damn easier............but can we control it in someway........
Suppose I open a word doc using Desktop, can I know whether the doc is still open or if it is closed............
Atleast Runtime returns a process for which we can wait for. Can we do something like that using Desktop.