Search Tools Links Login

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


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


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
End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 108 times


Visual Basic 6


No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.