Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Create a Shortcut and change icon

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,2776
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Create a Shortcut and change icon
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Create a Shortcut and change icon - 4/22/2005 4:08:50 AM   
  colbytrio

 

Posts: 27
Score: 1
Joined: 4/8/2005
From:
Status: offline
I was wondering if anyone can help me out on this issue... I need to create a shortcut for 350 user's and publish that shortcut on totheir desktop. I have searched the forums and didn't find any threads with what I am looking for.

I would like the VB startup script to create a shortcut on the user's desktop to webpage via Internet Explorer. The icon for this shortcut needs to be changed to an icon file either located on a server share or an icon file that has been copied to the user's local computer.

Thanks in advance!
 
 
Post #: 1
 
 Re: Create a Shortcut and change icon - 4/22/2005 6:11:50 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\blah.url")
objURLShortcut.TargetPath = "http://www.blah.com"
objURLShortcut.IconLocation "\\server\share\icon.ico
objURLShortcut.Save

(in reply to colbytrio)
 
 
Post #: 2
 
 Re: Create a Shortcut and change icon - 4/22/2005 6:21:08 AM   
  colbytrio

 

Posts: 27
Score: 1
Joined: 4/8/2005
From:
Status: offline
Thanks Token!

I owe you!

(in reply to colbytrio)
 
 
Post #: 3
 
 Re: Create a Shortcut and change icon - 4/22/2005 6:41:25 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
No problem =) and yes, you do

(in reply to colbytrio)
 
 
Post #: 4
 
 Re: Create a Shortcut and change icon - 4/22/2005 8:13:35 AM   
  colbytrio

 

Posts: 27
Score: 1
Joined: 4/8/2005
From:
Status: offline
Ok, everything is working perfectly with one exception: The icon will not change to the specified icon file. I receive the following error when running the script at the command prompt:

Microsoft VBscript runtime error: Object doesn't support this property or method 'objURLShortcut.IconLocation'

This is the code I am using:

'First, delete old shortcut with the same name.
on error resume next
Set objFSO1 = CreateObject("Scripting.FileSystemObject")
Set objShell1 = WScript.CreateObject("WScript.Shell")
strDesktopFld1 = objShell1.SpecialFolders("Desktop")
objFSO1.DeleteFile(strDesktopFld1 & "\insight.lnk") ' This is the shortcut you are looking to delete.

'Delete Quick Launch Icon
on error resume next
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
Set objShell2 = WScript.CreateObject("WScript.Shell")
Set colEnvironmentVariables = objShell2.Environment("Volatile")

' Also adds to the Quick Launch
on error resume next
strQLFolder2 = colEnvironmentVariables.Item("APPDATA") & _
"\Microsoft\Internet Explorer\Quick Launch"
objFSO2.DeleteFile(strQLFolder2 & "\insight.lnk") ' This is the shortcut you are looking to delete

'Create new shortcut with correct path.
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFld = objShell.SpecialFolders("Desktop")
Set objURLShortcut = objShell.CreateShortcut(strDesktopFld & "\BiTech.url") ' Name for Shortcut to add
objURLShortcut.TargetPath = "http://citrix" ' Path for shortcut
objURLShortcut.IconLocation "C:\test.ico"
objURLShortcut.Save

(in reply to colbytrio)
 
 
Post #: 5
 
 Re: Create a Shortcut and change icon - 4/22/2005 9:13:57 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
Apparently, IconLocation and Description are only supoprted with LNK objects, not URL objects.

(in reply to colbytrio)
 
 
Post #: 6
 
 Re: Create a Shortcut and change icon - 4/22/2005 10:35:00 AM   
  colbytrio

 

Posts: 27
Score: 1
Joined: 4/8/2005
From:
Status: offline
OK, I got it working...but now I'm having yet another problem.

I edited the script so it will go through a user's computer and remove shortcut's on the user's desktop and quick launch bar. It will also delete folders from the 'All Users' Programs folder. But I just found out these shortcuts and folders are profiles specific and not in the 'All Users' profile.

Culd someone please edit this script so it will delete the these specified shortcuts and folders from all of the profiles located on the machine (or from the ser who is logging into the syste).

Here is the code:


'This will delete the old BiTech Folders and Files from the Start Menu
on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefile "C:\Documents and Settings\All Users\Start Menu\insight.lnk", true

on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefile "C:\Documents and Settings\All Users\Start Menu\Click, Drag & Drill.lnk", true

on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefolder "C:\Documents and Settings\All Users\Start Menu\Programs\IFAS", true

on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefolder "C:\Documents and Settings\All Users\Start Menu\Programs\SunGard Bi-Tech", true



'This will delete the shortcuts on the Desktop and Quick Launch toolbar
'First, delete old shortcut with the same name.
on error resume next
Set objFSO1 = CreateObject("Scripting.FileSystemObject")
Set objShell1 = WScript.CreateObject("WScript.Shell")
strDesktopFld1 = objShell1.SpecialFolders("Desktop")
objFSO1.DeleteFile(strDesktopFld1 & "\insight.lnk") ' This is the shortcut you are looking to delete.

'Delete Quick Launch Icon
on error resume next
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
Set objShell2 = WScript.CreateObject("WScript.Shell")
Set colEnvironmentVariables = objShell2.Environment("Volatile")

' Also adds to the Quick Launch
on error resume next
strQLFolder2 = colEnvironmentVariables.Item("APPDATA") & _
"\Microsoft\Internet Explorer\Quick Launch"
objFSO2.DeleteFile(strQLFolder2 & "\insight.lnk") ' This is the shortcut you are looking to delete


' VBScript code follows...
' - Run Notepad.EXE
' - Copy-paste the code from below.
' - Save the file as Shortcut.VBS
Dim WSHShell
Dim MyShortcut
Dim DesktopPath

On Error resume next
Set WSHShell = CreateObject("WScript.Shell")
If not WSHShell Is Nothing Then
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set MyShortcut = WSHShell.CreateShortCut(DesktopPath & "\Bi-Tech ASP" & ".lnk")
MyShortcut.TargetPath = "http://server/citrix/metaframexp"
MyShortcut.WorkingDirectory = "http://server/citrix/metaframexp"
MyShortcut.WindowStyle = 1
MyShortcut.Arguments = ""
MyShortcut.IconLocation = "\\susd-adm1\install\citrixweb\insight.exe,0"
MyShortcut.Save
Set MyShortcut = Nothing
end if

(in reply to colbytrio)
 
 
Post #: 7
 
 Re: Create a Shortcut and change icon - 4/22/2005 10:45:38 AM   
  colbytrio

 

Posts: 27
Score: 1
Joined: 4/8/2005
From:
Status: offline
OK, I got it working...but now I'm having yet another problem.

I edited the script so it will go through a user's computer and remove shortcut's on the user's desktop and quick launch bar. It will also delete folders from the 'All Users' Programs folder. But I just found out these shortcuts and folders are profiles specific and not in the 'All Users' profile.

Culd someone please edit this script so it will delete the these specified shortcuts and folders from all of the profiles located on the machine (or from the ser who is logging into the syste).

Here is the code:


'This will delete the old BiTech Folders and Files from the Start Menu
on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefile "C:\Documents and Settings\All Users\Start Menu\insight.lnk", true

on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefile "C:\Documents and Settings\All Users\Start Menu\Click, Drag & Drill.lnk", true

on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefolder "C:\Documents and Settings\All Users\Start Menu\Programs\IFAS", true

on error resume next
set fso = createobject("scripting.filesystemobject")
fso.deletefolder "C:\Documents and Settings\All Users\Start Menu\Programs\SunGard Bi-Tech", true



'This will delete the shortcuts on the Desktop and Quick Launch toolbar
'First, delete old shortcut with the same name.
on error resume next
Set objFSO1 = CreateObject("Scripting.FileSystemObject")
Set objShell1 = WScript.CreateObject("WScript.Shell")
strDesktopFld1 = objShell1.SpecialFolders("Desktop")
objFSO1.DeleteFile(strDesktopFld1 & "\insight.lnk") ' This is the shortcut you are looking to delete.

'Delete Quick Launch Icon
on error resume next
Set objFSO2 = CreateObject("Scripting.FileSystemObject")
Set objShell2 = WScript.CreateObject("WScript.Shell")
Set colEnvironmentVariables = objShell2.Environment("Volatile")

' Also adds to the Quick Launch
on error resume next
strQLFolder2 = colEnvironmentVariables.Item("APPDATA") & _
"\Microsoft\Internet Explorer\Quick Launch"
objFSO2.DeleteFile(strQLFolder2 & "\insight.lnk") ' This is the shortcut you are looking to delete


' VBScript code follows...
' - Run Notepad.EXE
' - Copy-paste the code from below.
' - Save the file as Shortcut.VBS
Dim WSHShell
Dim MyShortcut
Dim DesktopPath

On Error resume next
Set WSHShell = CreateObject("WScript.Shell")
If not WSHShell Is Nothing Then
DesktopPath = WSHShell.SpecialFolders("Desktop")
Set MyShortcut = WSHShell.CreateShortCut(DesktopPath & "\Bi-Tech ASP" & ".lnk")
MyShortcut.TargetPath = "http://server/citrix/metaframexp"
MyShortcut.WorkingDirectory = "http://server/citrix/metaframexp"
MyShortcut.WindowStyle = 1
MyShortcut.Arguments = ""
MyShortcut.IconLocation = "\\susd-adm1\install\citrixweb\insight.exe,0"
MyShortcut.Save
Set MyShortcut = Nothing
end if

(in reply to colbytrio)
 
 
Post #: 8
 
 Re: Create a Shortcut and change icon - 4/22/2005 11:31:14 AM   
  token

 

Posts: 1917
Score: 0
Joined: 1/14/2005
From:
Status: offline
I don't understand exactly what you need help with. Does the script not working ? If so, what's the error message and at what line. If you need help with something else, you need to be specific and point out exactly what lines that you need help with.

(in reply to colbytrio)
 
 
Post #: 9
 
 Re: Create a Shortcut and change icon - 4/24/2005 12:17:47 AM   
  barocco


Posts: 49
Score: 0
Joined: 4/24/2005
From:
Status: offline
founded in Windows Me:
' Windows Script Host Sample Script
'
' ------------------------------------------------------------------------
' Copyright (C) 1996-1997 Microsoft Corporation
'
' You have a royalty-free right to use, modify, reproduce and distribute
' the Sample Application Files (and/or any modified version) in any way
' you find useful, provided that you agree that Microsoft has no warranty,
' obligations or liability for any Sample Application Files.
' ------------------------------------------------------------------------


' This sample demonstrates how to use the WSHShell object to create a shortcut
' on the desktop.

L_Welcome_MsgBox_Message_Text = "?E?A+?? L_Welcome_MsgBox_Title_Text = "Windows Scripting Host ·Ay"
Call Welcome()

' ********************************************************************************
' *
' * Shortcut related methods.
' *

Dim WSHShell
Set WSHShell = WScript.CreateObject("WScript.Shell")


Dim MyShortcut, MyDesktop, DesktopPath

' Read desktop path using WshSpecialFolders object
DesktopPath = WSHShell.SpecialFolders("Desktop")

' Create a shortcut object on the desktop
Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\notepad ?A?i?Y·?E?.lnk")

' Set shortcut object properties and save it
MyShortcut.TargetPath = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe")
MyShortcut.WorkingDirectory = WSHShell.ExpandEnvironmentStrings("%windir%")
MyShortcut.WindowStyle = 4
MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\notepad.exe, 0")
MyShortcut.Save

WScript.Echo "OU?AA?EION??OU Notepad ?A?i?Y·?E???"

' ********************************************************************************
' *
' * Welcome
' *
Sub Welcome()
Dim intDoIt

intDoIt = MsgBox(L_Welcome_MsgBox_Message_Text, _
vbOKCancel + vbInformation, _
L_Welcome_MsgBox_Title_Text )
If intDoIt = vbCancel Then
WScript.Quit
End If
End Sub

(in reply to colbytrio)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Create a Shortcut and change icon Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts