Is there any way that I can open notepad or other application from shortcuts?
Here is my code:
import java.io.File;
import java.io.IOException;
public class acrobat {
public static void main(String[] args) throws IOException, InterruptedException {
String[] notepad = {"C:\\Users\\Desktop\\notepad.lnk"};
Process p = Runtime.getRuntime().exec(notepad);
p.waitFor();
}
}
I want to open application from shortcut, but I am getting error..
Exception in thread "main" java.io.IOException: Cannot run program "C:\Users\robert\Desktop\notepad.lnk": CreateProcess error=193, %1 is not a valid Win32 application
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at acrobat.main(acrobat.java:11)
Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 4 more
If I only write notepad.exe than its working but, with path its not working. Is there any way that I can open with shortcuts?
.lnk
, that's why the program can't find the file specified. The.exe
is in the programs folder, the.lnk
links the desktop shortcut to the executable in the programs folder, on the desktop you have to look fornotepad.lnk
– BackSlash Jul 25 '13 at 13:56dir
and you can see what files there are. – m0skit0 Jul 25 '13 at 14:00C:\Users\Desktop\robert
orC:\Users\Desktop
? Typically you'd have a username in such a path. – reto Jul 25 '13 at 14:02