Google Groups

Re: Creating desktop shortcut icons

Torgeir Bakken (MVP) Jan 24, 2005 8:50 AM
Posted in group: microsoft.public.scripting.vbscript
Nick Fletcher wrote:

> Please can some help me.
> I need to create a shortcut on the users All users\Desktop folder.
> Can someone help with a sampel script please?
> FYI the shortcut is called Compass. It currently resides in
> \\myserver\desktop shotcuts\ and I would like it to go to C:\Documents and
> settings\All users\desktop

Here is an example:


' Create Lock Workstation shortcut in the All Users Desktop folder

Set oShell = CreateObject("WScript.Shell")

sAllUsersDesktopPath = oShell.SpecialFolders("AllUsersDesktop")

sWinSysDir = oShell.ExpandEnvironmentStrings("%SystemRoot%\System32")

Set oShortCut = oShell.CreateShortcut( _
         sAllUsersDesktopPath & "\Lock Workstation.lnk")

oShortCut.TargetPath = sWinSysDir & "\Rundll32.exe"
oShortCut.Arguments = "User32.dll,LockWorkStation"
oShortCut.IconLocation = sWinSysDir & "\Shell32.dll,47"

MsgBox "Lock Workstation shortcut is now created.", _
         vbInformation + vbSystemModal, "Create shortcut"

WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:

torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide: