Jump to Real's How-to Main page

Execute a Windows Shortcut (.lnk)

A Shortcut is stored in a file with the extension lnk.
// we assume that the .lnk is in the current directory
String currentDir = new File(".").getCanonicalPath();

try {
   Runtime.getRuntime().exec
      ("cmd /c start " + currentDir + "/viewLog.lnk");
}

catch (Exception e){
   JOptionPane.showMessageDialog
      (null, e.getMessage(),"Oups", JOptionPane.ERROR_MESSAGE);
}

If you find this article useful, consider making a small donation
to show your support for this Web site and its content.

Written and compiled by Réal Gagnon ©1998-2007
[ home ]