Questions tagged [lnk]

Use this tag for questions about Windows .lnk files representing Shortcuts (or Shell Links). For questions about link errors after compilation (of for example C/C++ code) use the tag [linker-error]

Use this tag if your question is about working with the .lnk (Shell Links) files from a programming perspective.

This can include:

  • the creation of such .lnk files,
  • the required registry keys,
  • its installation by means of a setupprogram,
  • its binary format
  • the relation with IShellLink

Notice that in Unix variants those files are sometimes called .Desktop files.

Wikipedia reference

128 questions
48
votes
11 answers

Reading the target of a .lnk file in Python?

I'm trying to read the target file/directory of a shortcut (.lnk) file from Python. Is there a headache-free way to do it? The spec is way over my head. I don't mind using Windows-only APIs. My ultimate goal is to find the "(My) Videos" folder on…
Etienne Perot
  • 4,764
  • 7
  • 40
  • 50
29
votes
1 answer

Creating a file shortcut (.lnk)

I have been looking for a simple way to create a shortcut to a file in C#, but I've only found external dlls that do that. It's actually quite surprising, there's no built in way to do that.. Anyway, I know that lnk files are just text files with a…
user2599803
  • 299
  • 1
  • 3
  • 7
26
votes
9 answers

Windows shortcut (.lnk) parser in Java?

I'm currently using Win32ShellFolderManager2 and ShellFolder.getLinkLocation to resolve windows shortcuts in Java. Unfortunately, if the Java program is running as a service under Vista, getLinkLocation, this does not work. Specifically, I get an…
Zarkonnen
  • 22,200
  • 14
  • 65
  • 81
8
votes
1 answer

Produce lnk file on GNU/Linux to transfer to windows

I'll explain my goal first to avoid "XY Problem" misunderstandings. I want to be able to produce a file (on Linux) that, when downloaded to a Windows machine and double clicked, will open a (ms office, but it shouldn't matter IIUC) file with a known…
silviot
  • 4,615
  • 5
  • 38
  • 51
6
votes
1 answer

Windows shortcut not displaying correctly in taskbar until reboot

When my MSI package upgrade installation is completed, all shortcuts immediately work as expected, except that the label in the taskbar refers to the binary being executed, rather than giving the shortcut link (and icon). After a reboot, the link…
Martin v. Löwis
  • 124,830
  • 17
  • 198
  • 235
5
votes
3 answers

Accessing target path from a shortcut file on a 64 bit system using 32 bit application

I'm trying to access the target path from a shortcut(.lnk) file on a 64bit machine using my 32 bit application. To get the path, I was using the following code. WshShell shell = new WshShell(); IWshShortcut link =…
Jimesh
  • 113
  • 6
5
votes
1 answer

How to track .lnk files in git?

I have .lnk files in my git repo. And other users are able to use them after cloning the repo successfully. However, once you have used it (clicked on it for example), it automatically becomes modified in git. Is there a way to avoid this? In…
Artemy
  • 245
  • 1
  • 10
5
votes
0 answers

Get target of Windows .lnk shortcut using "Start in" directory

I am trying to retrieve the target path of a Windows .lnk shortcut, but the "Target" is not an actual file path according to the .lnk file's properties: I am using the IWshRuntimeLibrary and the shortcut object I am accessing is of type…
kreddkrikk
  • 389
  • 3
  • 12
5
votes
1 answer

Qt/Win Creating app shortcuts

In Qt I know you can create a shortcut (lnk) using the following method QFile::link("myapp.exe", "myapp.exe.lnk"); This works fine but I want to create an lnk that also has some arguments in the target path. Anyway to do this in Qt?
Kal
  • 2,239
  • 6
  • 36
  • 74
4
votes
1 answer

change the icon of a windows shortcut .lnk file using python

I want to change the icon of a .lnk file after I have created it. This is my main code so far: import win32com.client shell = win32com.client.Dispatch("WScript.Shell") shortcut = shell.CreateShortCut("shortcut.lnk") shortcut.Targetpath =…
56-
  • 556
  • 5
  • 11
4
votes
1 answer

Read the Target of a Shortcut using Go

I'm trying to read the target file/directory of a shortcut (.lnk) file using Go. I already have a loop for all the files in a directory and I can successfully identify if it is a dir with IsDir() or if it is a file IsRegular(). Now I need a way to…
Emi
  • 525
  • 1
  • 3
  • 21
4
votes
3 answers

How can I change icons for existing URL shortcuts using Powershell?

I am wanting to change the icon for an existing shortcut using Powershell. I played around with it but I couldn't set the changes so I went online and came up empty-handed. I've seen examples with VB and Command Shell but nothing with Powershell.…
Rincewind
  • 412
  • 1
  • 10
  • 26
4
votes
2 answers

Bat file to create a Windows 7 shortcut.lnk on my desktop

How can I create a bat or vbs file to create a Windows 7 compatible desktop shortcut? I need the bat or vbs file to create the desktop shortcut using the following target and start-in locations (below). I basically created a desktop app that uses…
Jay
  • 73
  • 1
  • 2
  • 8
3
votes
1 answer

create a shortcut(.lnk) of file in windows with python3

i want to create a shortcut(.lnk) of some files in some specific path. for example make shortcut of my file("D:\New folder\new.exe") in ("H:\happy\hi\new.lnk") i want to write this program in python3
3
votes
2 answers

Wine linker error: trying to create .lnk

I'm trying to create an .lnk file programatically. I would prefer to use C, but C++ is fine (and is what all the MSDN stuff is in). The relevant code sample is: #include #include #include HRESULT…
singpolyma
  • 10,999
  • 5
  • 47
  • 71
1
2 3
8 9