There are some files from windows that I'd like to open on ubuntu. I went to my Windows desktop and found the files that I needed, but they were all .lnk. Ubuntu doesn't recognize these, so I can't trace them back to their origin and open them with wine. I'm on version 15.10, but I'm gonna upgrade 16.04 soon, though.
-
Related: https://superuser.com/questions/782135/how-do-i-dump-information-from-a-windows-lnk-shortcut-on-linux – Nathaniel M. Beaver Jul 31 '19 at 19:11
3 Answers
On Ubuntu, the larger issue with using
Windows shortcut files
(a.k.a.
.lnk
files or
shell links)
is that they may point to paths that do not exist on Ubuntu,
such as C:\Program Files
.
Relative paths might be analogous,
but then there is the path separator problem (\
and /
),
case-insensitive semantics to deal with
(on Windows, "Program Files" and "program files" are the same folder),
and encoding issues (what if the path contains characters besides ASCII?).
So even if file managers on Ubuntu supported the
proprietary format
to get the file paths,
that wouldn't mean the shortcut would work on Ubuntu,
since paths are not always portable.
That said, the
file
command will give you basic information about a link file.
$ file 'Program Files - Shortcut.lnk'
Program Files - Shortcut.lnk: MS Windows shortcut, Item id list present, Points to a file or directory, Has Relative path, Read-Only, Directory, ctime=Tue Jul 14 09:20:08 2009, mtime=Wed Apr 24 03:36:46 2019, atime=Wed Apr 24 03:36:46 2019, length=12288, window=hide
For more thorough information,
you can use the
lnkinfo
program from the
liblnk-utils
package.
Look for the "Local path" and "Relative path"
to trace where they were pointing to.
Here is an example of the lnkinfo
output to show what I mean:
$ lnkinfo 'Program Files - Shortcut.lnk'
lnkinfo 20171101
Windows Shortcut information:
Contains a link target identifier
Contains a relative path string
Link information:
Creation time : Jul 14, 2009 03:20:08.555426400 UTC
Modification time : Apr 23, 2019 21:36:46.017274100 UTC
Access time : Apr 23, 2019 21:36:46.017274100 UTC
File size : 12288 bytes
Icon index : 0
Show Window value : 0x00003000
Hot Key value : 12288
File attribute flags : 0x00000011
Is read-only (FILE_ATTRIBUTE_READ_ONLY)
Is directory (FILE_ATTRIBUTE_DIRECTORY)
Drive type : Fixed (3)
Drive serial number : 0x0e1909c6
Volume label : Local Disk
Local path : C:\Program Files
Relative path : ..\..\..\Program Files
Link target identifier:
Shell item list
Number of items : 3
Shell item: 1
Item type : Root folder
Class type indicator : 0x1f (Root folder)
Shell folder identifier : 20d04fe0-3aea-1069-a2d8-08002b30309d
Shell folder name : My Computer
Shell item: 2
Item type : Volume
Class type indicator : 0x2f (Volume)
Volume name : C:\
Shell item: 3
Item type : File entry
Class type indicator : 0x31 (File entry: Directory)
Name : PROGRA~1
Modification time : Apr 23, 2019 21:36:48
File attribute flags : 0x00000011
Is read-only (FILE_ATTRIBUTE_READ_ONLY)
Is directory (FILE_ATTRIBUTE_DIRECTORY)
Extension block: 1
Signature : 0xbeef0004 (File entry extension)
Long name : Program Files
Localized name : @shell32.dll,-21781
Creation time : Jul 14, 2009 03:20:10
Access time : Apr 23, 2019 21:36:48
NTFS file reference : MFT entry: 878, sequence: 1
Distributed link tracking data:
Machine identifier : nathaniel-pc
Droid volume identifier : b2638d5e-f5b8-480c-bda0-fdb25ab91131
Droid file identifier : 968b84a2-a646-11e9-a124-0021cc6948e3
Birth droid volume identifier : b2638d5e-f5b8-480c-bda0-fdb25ab91131
Birth droid file identifier : 968b84a2-a646-11e9-a124-0021cc6948e3

- 1,518
- 12
- 33
By default, programs in Windows are installed to one of these two locations:
C:\Program Files
C:\Program Files (x86)
(The second one will only exist if you have a 64-bit installation.)
On Ubuntu, these paths translate to:
WindowsDriveName >> /Program Files
WindowsDriveName >> /Program Files (x86)
You'll be able to find your programs in either of these folders.
Keep in mind: Many Windows programs can only be run in the environment where they were installed. That means that opening a program in Ubuntu that's been installed in Windows may not work correctly, if at all.
The best thing to do is just to use Wine to run the setup program for the app you want, so that it has its own environment in Ubuntu.

- 19,395
- 12
- 50
- 65
This is an example of a desktop entry created when installing Epic Games Launcher, this is simply an example.
[Desktop Entry]
Comment[en_US]=
Comment=
Exec=env WINEPREFIX="/home/whitequill/Games/epic-games-store" wine C:\\\\Users\\\\whitequill\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start\\ Menu\\\\Programs\\\\Epic\\ Games\\ Launcher.lnk
GenericName[en_US]=
GenericName=
Icon=ED2E_EpicGamesLauncher.0
MimeType=
Name[en_US]=Epic Games Launcher
Name=Epic Games Launcher
Path=/home/whitequill/Games/epic-games-store/drive_c/Program Files (x86)/Epic Games/Launcher/Portal/Binaries/Win64/
StartupNotify=true
StartupWMClass=EpicGamesLauncher.exe
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
As can be seen in the example the command under Exec is:
Exec=env WINEPREFIX="/home/whitequill/Games/epic-games-store" wine C:\\\\Users\\\\whitequill\\\\AppData\\\\Roaming\\\\Microsoft\\\\Windows\\\\Start\\ Menu\\\\Programs\\\\Epic\\ Games\\ Launcher.lnk
This shows executing a lnk file from a desktop script as for the lnk file. I would suggest following the information here: Ubuntu 20.04 - WineHQ 6.0 - Create .lnk shortcut for a program Which has the following script:
lnk () {
cat <<EOF > /tmp/shortcut.vbs
Set FSO = CreateObject("Scripting.FileSystemObject")
TargetPath = FSO.GetAbsolutePathName(WScript.Arguments(0))
WorkingDirectory = FSO.GetParentFolderName(TargetPath)
Set lnk = CreateObject("WScript.Shell").CreateShortcut(WScript.Arguments(1))
lnk.TargetPath = TargetPath
lnk.WorkingDirectory = WorkingDirectory
lnk.Save
EOF
wine wscript '//B' 'Z:\tmp\shortcut.vbs' "$@" 2> /dev/null
local exit_code=$?
sync; rm -f /tmp/shortcut.vbs; sync
return $exit_code
}
The following script for creating a lnk file is used to create a new lnk because the lnk is probably not going to work. In this example I was trying to run the Epic Games store and I needed to create a new link which looked like so:
lnk 'Z:\home\whitequill\Games\epic-games-store\drive_c\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win64\EpicGamesLauncher.exe' 'Z:\home\whitequill\Games\epic-games-store\drive_c\Users\whitequill\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Epic Games Launcher.lnk'
This is how you can you make a Desktop Entry which runs a windows shortcut, (.lnk) file.

- 101