Search
Enter Keywords:
Home
Create a Desktop Shortcut with VBScript PDF Print E-mail
User Rating: / 2
PoorBest 
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 )
< Previous   Next >

Main Menu
Home
Blog
Photos
Links
Search
Site Index
Feedback
Administrator
Featured Links
BlogInspiration
SpamToons
Shawn Prince's Blog
Jack Ludwig's Blog
Mike Cramer's Site
Fark
Slashdot
Woot!
Cigar Envy
John Kricfalusi's Blog
CigarBlog 101
Cigars 101 Forum
Sponsored Links


View Site Stats