|
Create a Desktop Shortcut with VBScript |
|
|
|
|
Written by Michael Salsbury
|
|
Tuesday, 05 June 2007 |
|
If you're trying to sort out how to create a Windows Shortcut on the desktop from within VBScript (or VB6) the following code should do the trick for you. It creates a shortcut on your desktop that launches the Notepad application. With some modification, it should allow you to create any desktop shortcut you need. Set WSHShell = WScript.CreateObject("WScript.Shell") ' Use WshSpecialFolders object to get to the Desktop DesktopPath = WSHShell.SpecialFolders("Desktop") ' Use the Shell to create a shortcut to Notepad on the desktop Set theShortcut = WSHShell.CreateShortcut(DesktopPath & "\Shortcut to notepad.lnk") ' Set shortcut object properties and save it theShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe") theShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%") theShortcut.WindowStyle = 4 theShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe, 0") theShortcut.Save
Related Blogs:
Related Links:
|
|
Last Updated ( Tuesday, 05 June 2007 )
|