VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Create A Windows Shortcut With 9 Lines Of Code

by TfAv1228 (1 Submission)
Category: Files/File Controls/Input/Output
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

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

Inputs
here is an examle of the code this will work with Windows XP CreateShortcut("C:\CMD.lnk", "C:\Windows\System32\CMD.exe", "CTRL+D", "Shortcut to CMD.exe") Would create a shortcut to the C:\Windows\System32\CMD.exe and place it at C:\CMD.lnk with a hotkey of CTRL+D and a description of Shortcut to CMD.exe

Rate Create A Windows Shortcut With 9 Lines Of 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

Download this snippet    Add to My Saved Code

Create A Windows Shortcut With 9 Lines Of Code Comments

No comments have been posted about Create A Windows Shortcut With 9 Lines Of Code. Why not be the first to post a comment about Create A Windows Shortcut With 9 Lines Of Code.

Post your comment

Subject:
Message:
0/1000 characters