https://github.com/darealshinji/mkshortcut
Create a Shell Link a.k.a. Shortcut on Windows from command line
https://github.com/darealshinji/mkshortcut
link shell-link shortcut windows
Last synced: about 1 year ago
JSON representation
Create a Shell Link a.k.a. Shortcut on Windows from command line
- Host: GitHub
- URL: https://github.com/darealshinji/mkshortcut
- Owner: darealshinji
- License: other
- Created: 2020-12-13T10:18:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-24T20:09:24.000Z (over 1 year ago)
- Last Synced: 2025-03-27T10:46:51.304Z (over 1 year ago)
- Topics: link, shell-link, shortcut, windows
- Language: C++
- Homepage:
- Size: 53.7 KB
- Stars: 12
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This is a simple C++ command line program to create so-called Shell Links, also known as Shortcuts or .lnk files.
Motivation for writing it was the lack of such a tool coming preinstalled on Windows 10 (mklink.exe
is for hard/symbolic links) and to get a better understanding on how to use the IShellLink class.
It was published into its own repository in the hope that people will have it easier to find it.
Check out https://github.com/libyal/liblnk if you don't want to use the Windows API.
Notes:
* released under MIT license
* does not create .url files (those are text files in an INI format)
* no header file, just copy the code you need
* Unicode and ANSI using `tchar.h`
* requires linkage against `ole32.lib` on MSVC and `-lole32 -luuid` on GCC/MinGW
Compile:
* Visual Studio 2019: open the provided solution file (mkshortcut.sln) and select *Build* -> *Build solution*
* the provided Makefile works with Microsoft nmake and GNU make
Usage example
-------------
*(assuming Firefox installed in typical directory)*
Open a command promt, move to Firefox's directory and create a shortcut:
```
cd "C:\Program Files\Mozilla Firefox"
C:\path\to\mkshortcut.exe /o:"%homedrive%%homepath%\Desktop\Firefox in disguise.lnk" ^
/t:firefox.exe /tfull /w:"C:/" /a:Windows ^
/i:"..\Internet Explorer\iexplore.exe" /ifull ^
/d:"Firefox (really)" /k:saf
```
`/o:"%homedrive%%homepath%\Desktop\Firefox in disguise.lnk"`
-> the shortcut will be placed on your desktop and called "Firefox in disguise" based on the filename
`/t:firefox.exe` -> shortcut target relative to your working directory
`/tfull` -> resolves relative path *firefox.exe* to the full path *"C:\Program Files\Mozilla Firefox\firefox.exe"*
`/w:"C:/"` -> set the working directory to *C:/*
`/a:Windows` -> launch Firefox with *Windows* as command line parameter;
this will make Firefox open *Windows* wich is resolved from the working directory (C:/) and therefor the contents of *C:\Windows* is shown
`/i:"..\Internet Explorer\iexplore.exe"` -> use the Internet Explorer icon
`/ifull` -> resolves *"..\Internet Explorer\iexplore.exe"* to the full path *"C:\Program Files\Internet Explorer\iexplore.exe"*
`/d:"Firefox (really)"` -> set tooltip description
`/k:saf` -> set "hotkey" to **S**hift+**A**lt+**F**; pressing this combination when being "on the desktop" will open the shortcut