I think you'll need to decode the LNK to get the actual EXE path/file.
Open shortcut (.lnk) with parameter lines Java
-
30-07-2022 - |
문제
I'd like to start a shortcut with parameter-lines How could I execute this shortcut with parameters in Java? (As this doesn't work with ProcessBuilder I'm stuck once again...)
"C:/Program Files/MyPrograms/MyShortcut.lnk" -s 3 -n 100 (what ever these parameter lines mean now)
I'm sucessfully able to launch my shortcut, without parameters.
code:
String directoryFile = "C:/Program Files/MyPrograms/MyShortcut.lnk"
Desktop.getDesktop().open(new File(directoryFile));
What I want:
String directoryFile = "C:/Program Files/MyPrograms/MyShortcut.lnk"
Desktop.getDesktop().open(new File(directoryFile)+"-s 3 -n 100");
This does work, but only for .exe files; I'd need to open a .lnk(win shortcut) with parameters
Process p = new ProcessBuilder("C:/Program Files/MyPrograms/MyFile.exe",
"-n", "100")
.start();
Thanks
해결책 2
다른 팁
If someone is looking for the same thing, this worked like a charm! (thanks to 'Glenn Lane' for linking me)
ProcessBuilder pb = new ProcessBuilder("cmd", "/c", "C:\\path\\shortcut.lnk", "-n", "100"); Process process = pb.start();
제휴하지 않습니다 StackOverflow