Results 1 to 3 of 3
  1. #1
    Uranium Lounger CWBillow's Avatar
    Join Date
    Jul 2002
    Location
    Las Vegas, NV USA
    Posts
    6,371
    Thanks
    78
    Thanked 12 Times in 11 Posts

    Mass-changes to a variable

    Is there any way that, if I have multiple shortcuts that include a variable [%var%], I can change all the shortcuts in one pass to implement a new variable?

    Regards,
    Chuck Billow
    -------------------------------------------------
    "Good judgment comes from experience, and experience - well, that comes from poor judgment."

    ~ A(lan) A(lexander) Milne (1882-1956)- "House at Pooh Corner"

  2. #2
    WS Lounge VIP
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    8,191
    Thanks
    48
    Thanked 985 Times in 915 Posts
    You would need to script it in something like VBS, open each shortcut, search for the variable, change and save if required. Not particularly useful for a one off.

    cheers, Paul

  3. #3
    Star Lounger
    Join Date
    Feb 2012
    Posts
    58
    Thanks
    2
    Thanked 5 Times in 4 Posts
    Quote Originally Posted by Paul T View Post
    You would need to script it in something like VBS, open each shortcut, search for the variable, change and save if required. Not particularly useful for a one off.

    cheers, Paul
    As you say, that would be a lot of effort for a one-off, but... What would the script look like, I wonder? Curiosity. Dead cats everywhere.

    My only idea, whether it be VBScript, PowerShell, or anything else, is this: Have WSH create an object for each shortcut, modify the TargetPath property (which corresponds to the "Target" field in the shortcut's properties dialog) and the WorkingDirectory property (which corresponds to the "Start in" field) if necessary, and save. Trouble is, these shortcut objects interpret variables. For example, target fields of
    %USERPROFILE%\AppData\Local\Temp\readme.txt
    %temp%\readme.txt
    and
    C:\Users\Fred\AppData\Local\Temp\readme.txt
    all look like
    C:\Users\Fred\AppData\Local\Temp\readme.txt
    in TargetPath. For a demonstration, save this little script to your Desktop with a .vbs extension and drag some shortcuts onto it. In no case will it show a variable.

    Code:
    Set objWshShell = WScript.CreateObject("WScript.Shell")
    For Each sLinkFile In WScript.Arguments
    	If LCase(Right(sLinkFile, 4)) <> ".lnk" Then
    		MsgBox sLinkFile & " - is not a .lnk file"
    	Else
    		MsgBox objWshShell.CreateShortcut(sLinkFile).TargetPath
    	End If
    Next

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •