wantabe2
asked on
VB Script Help
I have a VB script that runs at logon. This script creates some desktop shortcuts on the users computers. I've listed the code in this post. The script I've listed works great but now I have the need to update the link which I know all I need to do is edit the URL in the script but could someone tell me the code I need to delete the old URL/shortcuts from the desktop? Also, right now these shortcuts have the default blue IE icon as the picture. I have a tool to make an icon but how would I add that icon picture instead of the blue IE picture?
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
'a link to an app
'set objShortcut= objShell.CreateShortcut(strDesktopFolder & "\\Internet Explorer.lnk")
'objShortcut.TargetPath = "c:\Program Files\Internet Explorer\iexplore.exe"
'objShortcut.Hotkey = "CTRL+SHIFT+I"
'objShortcut.Description = "Launch Internet Explorer"
'objShortcut.WorkingDirectory = strDesktopFolder
'objShortcut.Save
'a web URL link
set objURL= objShell.CreateShortcut(strDesktopFolder & "\InOut Board.url")
objURL.TargetPath = "http://mysite.net"
objURL.Save
Of course, if you're using a certain icon from a DLL, you'd use something like:
objURL.IconLocation = "\\Server\Share\Icons\MyIc on.dll,5" 'where 5 is the cardinal number of the icon to reference
objURL.IconLocation = "\\Server\Share\Icons\MyIc
ASKER
Here's my new code:
I've also attached the error message in a .pdf file.
Any idea why I'm getting the VB error message? The folder on the server where the icon is is shared with EVERYONE full share & NTFS permissions.
I've also attached the error message in a .pdf file.
Any idea why I'm getting the VB error message? The folder on the server where the icon is is shared with EVERYONE full share & NTFS permissions.
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
'a link to an app
'set objShortcut= objShell.CreateShortcut(strDesktopFolder & "\\Internet Explorer.lnk")
'objShortcut.TargetPath = "c:\Program Files\Internet Explorer\iexplore.exe"
'objShortcut.Hotkey = "CTRL+SHIFT+I"
'objShortcut.Description = "Launch Internet Explorer"
'objShortcut.WorkingDirectory = strDesktopFolder
'objShortcut.Save
'a web URL link
set objURL= objShell.CreateShortcut(strDesktopFolder & "\InOut Board.url")
objURL.TargetPath = "http://156.125.44.140/iomain.php"
objURL.Save
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTS.url")
objURL.TargetPath = "https://site1.com"
objURL.Save
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTSV55T.url")
objURL.TargetPath = "https://site2.com"
objURL.Save
set objURL= objShell.CreateShortcut(strDesktopFolder & "\NewPACTSV55.url")
objURL.TargetPath = "https://site3.com"
objURL.IconLocation = "\\156.125.45.82\icons\pacts.ico"
objURL.Save
ASKER
The rror code did not upload for some reason but the VB error I am getting is on line 31. It says "Object doesn't support this property or method objURL.IconLocation
Ah, cause you have it as a URL, not a shortcut link...
Try this:
Try this:
Set objShell = WScript.CreateObject("WScript.Shell")
strDesktopFolder = objShell.SpecialFolders("Desktop")
'a link to an app
'set objShortcut= objShell.CreateShortcut(strDesktopFolder & "\\Internet Explorer.lnk")
'objShortcut.TargetPath = "c:\Program Files\Internet Explorer\iexplore.exe"
'objShortcut.Hotkey = "CTRL+SHIFT+I"
'objShortcut.Description = "Launch Internet Explorer"
'objShortcut.WorkingDirectory = strDesktopFolder
'objShortcut.Save
'a web URL link
set objURL= objShell.CreateShortcut(strDesktopFolder & "\InOut Board.url")
objURL.TargetPath = "http://156.125.44.140/iomain.php"
objURL.Save
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTS.url")
objURL.TargetPath = "https://site1.com"
objURL.Save
set objURL= objShell.CreateShortcut(strDesktopFolder & "\PACTSV55T.url")
objURL.TargetPath = "https://site2.com"
objURL.Save
set objURL= objShell.CreateShortcut(strDesktopFolder & "\NewPACTSV55.lnk")
objURL.TargetPath = "https://site3.com"
objURL.IconLocation = "\\156.125.45.82\icons\pacts.ico"
objURL.Save
ASKER
That works GREAT! Thank you. If I wanted to delete the ICON pushed out on lines 20, 21, and 22... if I rem out those lines the icon stays on the desktop after running this script. If I wanted to get rid of the icon pushed out on line 20, 21, and 22..what is the code to do that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I added that code to the end of my script I get the error:
FILE NOT FOUND referencing line - objFSO.DeleteFile strDesktopFolder & "\PACTSV55T.url"
As you can see I am clueless with VB :)
FILE NOT FOUND referencing line - objFSO.DeleteFile strDesktopFolder & "\PACTSV55T.url"
As you can see I am clueless with VB :)
ASKER
UPDATE
Ok, with the
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
objFSO.DeleteFile strDesktopFolder & "\PACTSV55T.url"
code in the script, it actually disables the icon by taking away the URL path but the icon is still there. Is there a way to totally get rid of the icon?
Ok, with the
Set objFSO = CreateObject("Scripting.Fi
objFSO.DeleteFile strDesktopFolder & "\PACTSV55T.url"
code in the script, it actually disables the icon by taking away the URL path but the icon is still there. Is there a way to totally get rid of the icon?
ASKER
The shortcut I'm trying to delete is an Internet shortcut if that helps...
Right-click the icon - what is the name of the file?
To point to the icon, you would use the IconLocation property.
Open in new window