Create A Windows Shortcut With 9 Lines Of Code
A Function To Create Windows Shorcut
.URL for hyperlinks
.LNK for anything else
There are many other variables that can be implemented besides just Name where it points hotkey and description
Original Author: TfAv1228
Inputs
here is an examle of the code
this will work with Windows XP
CreateShortcut("C:CMD.lnk", "C:WindowsSystem32CMD.exe", "CTRL+D", "Shortcut to CMD.exe")
Would create a shortcut to the C:WindowsSystem32CMD.exe and place it at C:CMD.lnk with a hotkey of CTRL+D and a description of Shortcut to CMD.exe
Code
Public Function CreateShortcut(ShortName As String, PointsTo As String, Optional HotKey As String = "", Optional Description As String = "")
Dim WS As Object, SC As Object
Set WS = CreateObject("Wscript.Shell")
Set SC = WS.CreateShortcut(ShortName)
SC.TargetPath = PointsTo
SC.HotKey = HotKey
SC.Description = Description
SC.Save
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.