Create shortcut VBScript


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'====================================================================
' NAME: <createAddRemoveShortCut.vbs>
'
' COMMENT: Key concepts are listed below:
'1. Uses wscript.shell to create shortcut on the desktop.
'2. The hard part was passing an argument to the target, which is not allowed
'3. in the target argument. You need to use the arguments property instead.
'====================================================================
Option Explicit
Dim objShell 'instance of the wshSHell object
Dim strDesktop 'pointer to desktop special folder
Dim objShortCut 'used to set properties of the shortcut. Comes from using createShortCut
Dim strTarget
strTarget = "control.exe"
set objShell = CreateObject("WScript.Shell")
strDesktop = objShell.SpecialFolders("Desktop")

set objShortCut = objShell.CreateShortcut(strDesktop & "\AddRemove.lnk")
objShortCut.TargetPath = strTarget
objShortCut.Arguments = "appwiz.cpl"
objShortCut.IconLocation = "%SystemRoot%\system32\SHELL32.dll,21"
objShortCut.description = "Add remove Programs"
objShortCut.Save



You can leave a response, or trackback from your own site.


Further Reading
    None Found




Leave a Reply

Anti-Spam Quiz:

Twitter Delicious Facebook Digg Stumbleupon Favorites More
334 queries in 4.556 seconds.