I have the following script which I ran from a network share. A desktop shortcut was created and an .ico file dropped onto the workstation. When I removed the vbscript from the server share the icon for the shortcut I created disappeared even though when you go into the shortcut the icon is still there to select and works fine afterwards. What happened?
Option Explicit
'***** Variable Declarations *****
Dim FSO, WshShell, Desktop, oShellLink
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Desktop = WshShell.SpecialFolders("ALLUsersDesktop")
' ***** Main Body *****
'Conditional Logic to Run Script
If FSO.FileExists(""&Desktop&"\app.lnk") Then
wscript.quit
Else
'Copy Icon File
FSO.CopyFile "\\servername\share\app.ico", "C:\", True
'Create Shortcut
set oShellLink = WshShell.CreateShortcut(Desktop & "\app.lnk")
oShellLink.IconLocation = "c:\app.ico"
oShellLink.TargetPath = "\\servername\sharename\launch.vbs"
oShellLink.WorkingDirectory = "C:\"
oShellLink.Save
End If
' ***** End of Script *****
Option Explicit
'***** Variable Declarations *****
Dim FSO, WshShell, Desktop, oShellLink
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshShell = WScript.CreateObject("WScript.Shell")
Desktop = WshShell.SpecialFolders("ALLUsersDesktop")
' ***** Main Body *****
'Conditional Logic to Run Script
If FSO.FileExists(""&Desktop&"\app.lnk") Then
wscript.quit
Else
'Copy Icon File
FSO.CopyFile "\\servername\share\app.ico", "C:\", True
'Create Shortcut
set oShellLink = WshShell.CreateShortcut(Desktop & "\app.lnk")
oShellLink.IconLocation = "c:\app.ico"
oShellLink.TargetPath = "\\servername\sharename\launch.vbs"
oShellLink.WorkingDirectory = "C:\"
oShellLink.Save
End If
' ***** End of Script *****