VBScript - Modify a shortcut (NOT CREATE ANOTHER ONE)

Posted on 2006-04-14
Last Modified: 2010-08-13
     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,
Question by:JayTreDoe357
    LVL 41

    Accepted Solution

    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 ?

    Author Comment

    The problem with that is... how do I read what is already there for targetpath?
    LVL 41

    Expert Comment

    set link = shell.CreateShortcut(SomePathToAnExistingShortCut)
    if link.TargetPath <> TheNewLocation then
              link.TargetPath = TheNewLocation
    end if

    Author Comment

    Sorry yes you were correct on your first answer, I figured it out with your help. Thanks.

    Expert Comment

    What if I need a script that takes

    original shortcut

    and need to change

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    This is an explanation of a simple data model to help parse a JSON feed
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now