Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you create (and read) windows shortcut(.lnk file) in Java?

Tags:

Same question, different langauge.

How do you do it in Java? Do you use JNI? run exe? or are there any library read/write *.lnk like POI read/write *.xls?

I used to workaround to create ".url" which is plain text INI file. But I am looking for other interesting way to do it.

like image 899
Dennis C Avatar asked Dec 05 '08 13:12

Dennis C


People also ask

How do I create a .LNK shortcut?

doc file in a folder and select Copy and then right-click the Desktop and selectPaste Shortcut, Windows creates a . lnk file that points to the . doc file.

How do I create a shortcut to a file in Java?

Right-click on your . bat file or executable JAR file. Select Create Shortcut.

How do you read a .LNK file?

How to open an LNK file. Opening an LNK file, by double-clicking it or right-clicking it and selecting Open, opens the file, folder, or program to which the LNK file points. Advanced users can edit an LNK file's properties by right-clicking the file and selecting Properties.

What is a shortcut LNK file?

An LNK file is a Windows Shortcut that serves as a pointer to open a file, folder, or application. LNK files are based on the Shell Link binary file format, which holds information used to access another data object.


1 Answers

I would use a JNI interface if the goal is quality.

http://alumnus.caltech.edu/~jimmc/jshortcut/

For quick hacks, (on my workstation only) : System.Exec() a vbscript :-) (I know, i know).

like image 118
BraveSirFoobar Avatar answered Nov 15 '22 06:11

BraveSirFoobar