Change Windows shortcuts target path
My brother made a login on my computer and created a lot of windows shortcuts on his desktop and now the target path has changed so we need to modify these with a script.
Is there an easy way to do a recursive search for shortcut files and modify the target path for each one if it has a specific string in it?
Re: Change Windows shortcuts target path
VB Code:
Code:
'delete the flash shortcut
Dim shell As Object
Dim link As Object
Dim DesktopPath As String
Set shell = CreateObject("WScript.Shell")
DesktopPath = shell.SpecialFolders("AllUsersDesktop")
fso.DeleteFile DesktopPath & "Agent Prospecting Presentation.lnk"
'create a new flash shortcut
Set shell = CreateObject("WScript.Shell")
DesktopPath = shell.SpecialFolders("AllUsersDesktop")
Set link = shell.CreateShortcut(DesktopPath & "Agent Prospecting Presentation.lnk")
'link.Arguments = "1 2 3"
link.Description = "Agent Prospecting Presentation"
'link.HotKey = "CTRL+ALT+SHIFT+X"
link.IconLocation = "C:WestfieldInsuranceWestfield_1to1F_v1.exe,1"
link.TargetPath = "C:MyWestfieldPresentationWestfield_1to1F_v1.exe"
'window style 3=maximized, 2=normal
link.WindowStyle = 2
'start in
link.WorkingDirectory = "C:MyWestfieldPresentation"
link.Save
Re: Change Windows shortcuts target path
There is a program for MS Windows called shortcut. I use it to create shortcuts on the desktop, the start menu and URL shortcuts in Favourites.
Quote:
Shortcut [Version 1.10]
Creates, modifies or queries Windows shell links (shortcuts)
The syntax of this command is:
shortcut /F:filename /A:C|E|Q [/T:target] [/P:parameters] [/W:workingdir] [/R:runstyle] [/I:icon,index] [/H:hotkey] [/D:description]
/F:filename : Specifies the .LNK or .URL shortcut file.
/A:action : Defines the action to take (C=Create, E=Edit or Q=Query).
/T:target : Defines the target path and file name the shortcut points to.
/P:parameters : Defines the command-line parameters to pass to the target.
/W:working dir : Defines the working directory the target starts with.
/R:run style : Defines the window state (1=Normal, 3=Max, 7=Min).
/I:icon,index : Defines the icon and optional index (file.exe or file.exe,0).
/H:hotkey : Defines the hotkey, a numeric value of the keyboard shortcut.
/D:description : Defines the description (or comment) for the shortcut.