I have code in my app that deletes an existing icon and recreates it with a new target path. This is my code, it seems like over kill to me.

Is it possible to just change the target paths file name instead of deleting it and then recreating it?


VB Code:
  1. 'delete the flash shortcut
  2.     Dim shell As Object
  3.     Dim link As Object
  4.     Dim DesktopPath As String
  5.     Set shell = CreateObject("WScript.Shell")
  6.     DesktopPath = shell.SpecialFolders("AllUsersDesktop")
  7.     fso.DeleteFile DesktopPath & "\Agent Prospecting Presentation.lnk"
  8.  
  9.     'create a new flash shortcut
  10.     'because we are replacing the old exe
  11.     Set shell = CreateObject("WScript.Shell")
  12.     DesktopPath = shell.SpecialFolders("AllUsersDesktop")
  13.     Set link = shell.CreateShortcut(DesktopPath & "\Agent Prospecting Presentation.lnk")
  14.     'link.Arguments = "1 2 3"
  15.     link.Description = "Agent Prospecting Presentation"
  16.     'link.HotKey = "CTRL+ALT+SHIFT+X"
  17.     link.IconLocation = "C:\WestfieldInsurance\Westfield_1to1F_v1.exe,1"
  18.     link.TargetPath = "C:\MyWestfieldPresentation\Westfield_1to1F_v1.exe"
  19.     'window style 3=maximized, 2=normal
  20.     link.WindowStyle = 2
  21.     'start in
  22.     link.WorkingDirectory = "C:\MyWestfieldPresentation"
  23.     link.Save