I'd like to automate the creation of a shortcut that points to a URL (with a specified icon image).
Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

3
We created a shortcut with the icon, and zipped it up. Added it as a dependency, and then used a batch file to copy it to the Public Desktop for Windows 7. For XP you could copy it to the All Users Desktop.
Answered 03/19/2012 by: WGM_Jeff
Fourth Degree Black Belt

  • Wow.... so much easier then the way I was doing it.
Please log in to comment

Answers

2
I have a installation I run from a powershell script and part of the install is to create an icon. Although, It might be overly complicated for what you need.

$shortcut_name = "Name"
$shortcut_target = "URL"
$sh = new-object -com "WScript.Shell"
$p = $sh.SpecialFolders.item("AllUsersDesktop")
$lnk = $sh.CreateShortcut( (join-path $p $shortcut_name) + ".lnk" )
$lnk.TargetPath = $shortcut_target
$lnk.IconLocation = "C:\Windows\System32\url.dll"
$lnk.Save()
Answered 03/22/2012 by: andibogard
Blue Belt

Please log in to comment
1
' Below is a copy of a VBScript that I use to accomplish the job.
' This creates shortcuts on the desktop and on the quick lauch bar

'VBScript Begins here
On error resume next

Dim WshShell
Dim strDesktopPath, strAllUsers, strCurrentUser, QuickLaunch, strIconPath

Set WshShell = CreateObject("WScript.Shell")

strDesktopPath = WshShell.ExpandEnvironmentStrings("%AllUsersProfile%") & "\Desktop"
strAllUsers = WshShell.ExpandEnvironmentStrings("%AllUsersProfile%")
strCurrentUser = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Application Data\Microsoft\Internet Explorer\Quick Launch"
QuickLaunch = WshShell.ExpandEnvironmentStrings("%AllUsersProfile%") & "\Application Data\Microsoft\Internet Explorer\Quick Launch"


'Set the path to your custom icon below
strIconPath = strAllUsers & "\Application Data\YourIcons\MyIcon.ico"

Get_CopyIcon
Get_CreateShortcuts


Sub Get_CopyIcon

Set fso = CreateObject("Scripting.FileSystemObject")

'Copies your custom icon to the folder below, change "YourIcon" to your icon path
strFolder = strAllUsers & "\Application Data\YourIcons"
strFile = "MyIcon.ico"


'Copy 1
If not fso.FolderExists(strFolder) Then
FSO.CreateFolder strFolder
End If

If fso.FileExists(strIconPath) Then
FSO.DeleteFile strIconPath,True
End If

FSO.CopyFile strFile, strIconPath,True


End Sub

Sub Get_CreateShortcuts

'Add your URL on the line below
strURL = "http://www.itninja.com/question/how-to-create-desktop-url-with-icons"


Set objShortcutUrl = WshShell.CreateShortcut(strDesktopPath & "\Name of your link.lnk")
objShortcutUrl.TargetPath = strURL
objShortcutUrl.IconLocation = strIconPath
objShortcutUrl.Save


Set objShortcutUrl = WshShell.CreateShortcut(QuickLaunch & "\Your Link Name.lnk")
objShortcutUrl.TargetPath = strURL
objShortcutUrl.IconLocation = strIconPath
objShortcutUrl.Save

Set objShortcutUrl = WshShell.CreateShortcut(strCurrentUser & "\Your Link Name.lnk")
objShortcutUrl.TargetPath = strURL
objShortcutUrl.IconLocation = strIconPath
objShortcutUrl.Save

End Sub

'End of VBScript
Answered 03/26/2012 by: NinjaInPA
Orange Senior Belt

Please log in to comment
This content is currently hidden from public view.

0
WinXP - create a .ico file and copy it to %systemroot%\system32. Create a .lnk file pointing to the .ico file in the system32 directory. Copy the .lnk file to the All Users Desktop.

Win7 - I created an MSI using InstallShield that accomplishes something very similar but all the files are contained in the install directory. This also gave us the ability to report what users had what desktop short-cuts using Add/Remove Programs.
Answered 03/20/2012 by: Trinity
Brown Belt

  • trinity do you have a msi to create a shortcut on a desktop for winxp and win7
Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share