Link to home
Start Free TrialLog in
Avatar of JayTreDoe357
JayTreDoe357

asked on

VBScript - Modify a shortcut (NOT CREATE ANOTHER ONE)

Greetings,
     I was wondering if there was anyway to modify a shortcut though a VBScript. EX) I have a desktop shortcut, that's path points to one server. I want to be able to run this script which MODIFYs the shortcuts path to point to another server. ie. original target path is \\server01\file.exe and I want it to point to \\server02\file.exe. I have searched the internet and I have only found how to create a new shortcut.

Thanks in advance,
Jason
ASKER CERTIFIED SOLUTION
Avatar of graye
graye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JayTreDoe357
JayTreDoe357

ASKER

The problem with that is... how do I read what is already there for targetpath?
set link = shell.CreateShortcut(SomePathToAnExistingShortCut)
if link.TargetPath <> TheNewLocation then
          link.TargetPath = TheNewLocation
          link.Save
end if
Sorry yes you were correct on your first answer, I figured it out with your help. Thanks.
What if I need a script that takes

original shortcut
\\server1\docs\project1

and need to change
\\server2\rootfolder\docs\project1

Essentially i need something that servers for "server1" and replaces it with \\server2\rootfolder\, and leaves the rest of the path intact as well.