windows_wiki:vbscript_-_icon_copy

This is an old revision of the document!


VBScript - Icon Copy

Script template to copy an external icon for use in a shortcut.

'==========================================================================
' VBScript:  AUTHOR: <name> <date>
' NAME: <Template-ExtIcon.vbs>
' DESCRIPTION: Copies an External Icon to C:\ if it does not already exist. 
'==========================================================================

'Declare Variables for later use
Option Explicit
Const OverwriteExisting = TRUE
Dim IconName
Dim CopyFrom
Dim CopyTo
Dim objIcon

'++++++++++++++++++++++++ EDIT THESE VARIABLES +++++++++++++++++++++++++++++

'Filename of Icon (include extension)
IconName = "Name.ico"

'Full network path of folder icon is in. (include trailing slash)
CopyFrom = "\\server\folder\"

'Full local directory to copy the icon to
CopyTo = "C:\"

'+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Set objIcon = CreateObject("Scripting.FileSystemObject")

If objIcon.FileExists(CopyTo & IconName) Then
  Wscript.Quit
Else
  ObjIcon.CopyFile CopyFrom & IconName , CopyTo, OverwriteExisting
End If
  • windows_wiki/vbscript_-_icon_copy.1416370932.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)