• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2893
  • Last Modified:

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
0
JayTreDoe357
Asked:
JayTreDoe357
  • 2
  • 2
1 Solution
 
grayeCommented:
Actually it's the same thing....   You use the Shell.CreateShortcut to both create a new shortcut *and* to modify an existing one.  So you probably already have the solution you need.

... I guess they were too lazy to come up with a EditShortcut method ?
0
 
JayTreDoe357Author Commented:
The problem with that is... how do I read what is already there for targetpath?
0
 
grayeCommented:
set link = shell.CreateShortcut(SomePathToAnExistingShortCut)
if link.TargetPath <> TheNewLocation then
          link.TargetPath = TheNewLocation
          link.Save
end if
0
 
JayTreDoe357Author Commented:
Sorry yes you were correct on your first answer, I figured it out with your help. Thanks.
0
 
SmallPrintCommented:
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.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now