While most people will never need to open a .lnk file to edit it, there may be rare occasions when it is necessary or desired. But how do you open and edit a shortcut file? Today’s SuperUser Q&A post has the answers.
Today’s Question & Answer session comes to us courtesy of SuperUser—a subdivision of Stack Exchange, a community-driven grouping of Q&A web sites.
The Question
SuperUser reader Jez wants to know how to open .lnk files to view the ‘contents’ and edit them if needed:
Is there a way for Jez to actually open .lnk files and edit them?
No matter what I try, my applications are opening the contents of the file it points to (drag and drop into a text or hex editor, File –> Open from a text or hex editor, etc.).
Is there any way I can get a program to actually open the .lnk file itself instead of the file it points to?
The Answer
SuperUser contributors and31415, Julian Knight, and Vinayak have the answer for us. First up, and31415:
Followed by the answer from Julian Knight:
As a workaround, open a command prompt and rename the .lnk file with a different, non-existent extension such as .lne:
cd /d “X:\Folder\containing\the\shortcut” ren “some shortcut. lnk” “some shortcut. lne”
You will then be able to treat the shortcut just like a regular file. When you are done, make sure to rename the file with the original .lnk extension to restore its usual functionality.
And finally, the answer from Vinayak:
If you really want to edit it, you need a special tool. There are a few of these around including:
lnk-parser LnkEditorGUI lnkedit
I have not tried any of these, just Googled them.
You can also edit the properties via PowerShell (from this previous answer on Stack Overflow):
Copy-Item $sourcepath $destination ## Get the lnk we want to use as a template $shell = New-Object -COM WScript. Shell $shortcut = $shell. CreateShortcut($destination) ## Open the lnk $shortcut. TargetPath = “C:\path\to\new\exe. exe” ## Make changes $shortcut. Description = “Our new link” ## This is the “Comment” field $shortcut. Save() ## Save
Since this uses the Shell COM object, you could also do this with WSH or even VBA in Office!
Have something to add to the explanation? Sound off in the comments. Want to read more answers from other tech-savvy Stack Exchange users? Check out the full discussion thread here.
Opening .lnk files in Notepad:
Just drag and drop them into the Notepad window. If you open them via the Open dialog, Notepad will open the exe file pointed to by the . lnk file.
Opening .lnk files in HxD Hex Editor:
Open them as you would any file using the Open dialog (File –> Open).
Opening .lnk files using the command prompt:
Navigate to the folder containing the . lnk files and type the command: “TYPE SHORTCUTNAME. LNK”.
Opening .lnk files in just about any program:
Start the command prompt, navigate to the folder where the program is located, use the command: PROGRAM_NAME. EXE “path to LNK file”.