Creating shortcuts

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Creating shortcuts

Post by Marcus Tettmar » Mon Feb 21, 2005 10:36 pm

This subroutine creates a desktop shortcut. It could be modified to create shortcuts in any other location:

VBSTART
Sub NewDesktopShortcut(linkfile,targetpath,windowstyle,hotkey,descr)
Set WshShell = CreateObject("Wscript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
set oShellLink = WshShell.CreateShortcut(strDesktop & "\" & linkfile)
oShellLink.TargetPath = targetpath
oShellLink.WindowStyle = windowstyle
oShellLink.Hotkey = hotkey
'oShellLink.IconLocation = "notepad.exe, 0"
oShellLink.Description = descr
oShellLink.WorkingDirectory = strDesktop
oShellLink.Save
End Sub
VBEND

VBRun>NewDesktopShortcut,My App.lnk,d:\my documents\someapp.exe,1,CTRL+SHIFT+C,My Shortcut

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts