Changing Target in Shortcut with VBScript

19,676

Solution 1

Here is the complete solution for your problem :

Set wsc = WScript.CreateObject("WScript.Shell")
Set lnk = wsc.CreateShortcut(wsc.SpecialFolders("desktop") & "\AE Client.LNK")

lnk.targetpath = "C:\Program Files\Hyland\Application Enabler\AEClient.exe"
lnk.Arguments = "\\rrscwpappimg02\Workflow\CWF\AppEnabler\CombinedCWF.xml"
lnk.save

Solution 2

The target path must be a string, so you need to change this:

lnk.targetpath = "C:\path\to\your.exe" \\server\share\path\to\file.xml

into this:

lnk.targetpath = """C:\path\to\your.exe"" \\server\share\path\to\file.xml"

Strings in VBScript must be in double quotes. Nested double quotes inside a string can be escaped by doubling them.

Share:
19,676
Admin
Author by

Admin

Updated on June 26, 2022

Comments

  • Admin
    Admin almost 2 years

    I am trying to create a VBScript to change a target in a link

    The current target is

    "C:\Program Files\Hyland\Application Enabler\AEClient.exe"
    

    I want the new target to be

    "C:\Program Files\Hyland\Application Enabler\AEClient.exe" \\rrscwpappimg02\Workflow\CWF\AppEnabler\CombinedCWF.xml
    

    Here is the script I have thus far. I keep getting an error on line 4 char 78:

    Set wsc = WScript.CreateObject("WScript.Shell")
    Set lnk = wsc.CreateShortcut(wsc.SpecialFolders("desktop") & "\AE Client.LNK")
    
    lnk.targetpath = "C:\Program Files\Hyland\Application Enabler\AEClient.exe"      \\rrscwpappimg02\Workflow\CWF\AppEnabler\CombinedCWF.xml
    lnk.description = "AE Client"
    lnk.workingdirectory = "C:\Program Files (x86)\Hyland\Application Enabler\"
    lnk.save`
    

    Any help would be greatly appreciated.

    Even just a script to create the shortcut that work on the desktop would work.