

' Requires reference to Windows Script Host Object Modelĭim oShell As IWshRuntimeLibrary.WshShellĭim oShortCut As IWshRuntimeLibrary.WshShortcut Optional ByVal eWinStyle As WshWindowStyle = vbNormalFocus, Optional ByVal iIconNum As Integer)

Private Sub Create_ShortCut(ByVal sTargetPath As String, ByVal sShortCutPath As String, ByVal sShortCutName As String, _ $Favorite = $Shell.CreateShortcut($env:USERPROFILE + "\Desktop\Your Shortcut.Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.ClickĬreate_ShortCut(Application.ExecutablePath, My., PageTitleLabel.Text, "/url=" & WebBrowserURL.Text, "",, Application.ExecutablePath) $Shell = New-Object -ComObject ("WScript.Shell") Step #5: As a bonus here is how you would create a Favorite in Windows which is a. Step #4: The final step is to envoke the Save() method to save your shortcut. $ShortCut.Description = "Your Custom Shortcut Description" $ShortCut.IconLocation = "yourexecutable.exe, 0" $ShortCut.WorkingDirectory = "c:\your\executable\folder\path" $ShortCut.Arguments="-arguementsifrequired" $ShortCut.TargetPath="yourexecutable.exe" Step #3: The third step is to add the target path, any relevant arguments, along with anything else that may be required. $ShortCut = $Shell.CreateShortcut($env:USERPROFILE + "\Desktop\Your Shortcut.lnk") The following example will add the shortcut to the user’s desktop with a name of Your Shortcut.

Step #2: The second step is to define the location and name of your shortcut. Step #1: The first step is to create a variable referencing a Wscript.Shell COM Object. Here is the quick run down with explanation. With PowerShell you can actually create a shortcut from scratch by utilizing the New-Object commandlet. Many people simply copy an already created shortcut. lnk files with a few details highlighting a few details of the file that you would like to launch. Have you ever needed to create shortcuts while scripting.
