You can replace all shortcuts under the specified directory and its subdirectories, specify the path to hold the shortcut, the string to be replaced, and the string you want to replace, and then double-click to run it.
Here is the code, not very complicated,:
Copy Code code as follows:
On Error Resume Next
' Replace the pointing path for all shortcuts under a folder and its subfolders
Strfolderpath= the path to the "D:\Program files\truelaunchbar\shortcut\file\ Style" shortcut
Strtoreplace= "\software\" ' Ring string
Strreplace= "\[software]\" replaced by a string
Set WshShell = CreateObject ("Shell.Application")
Set Wshfso = CreateObject ("Scripting.FileSystemObject")
Altersubfolders Wshfso.getfolder (Strfolderpath)
Sub altersubfolders (Folder)
Set Npfolder = Wshshell.namespace (Folder.path)
Set Allfiles=folder.files
For each lnkfile in Allfiles
' WScript.Echo Lnkfile.name
If InStrRev (UCase (Lnkfile.name), ". LNK ") <> 0 Then ' extension shortcuts
Set Lnkitem = Npfolder.parsename (lnkfile.name)
Set Lnkitemlink = Lnkitem.getlink
' WScript.Echo ' "" &lnkItemLink.Path& "" "
Lnkitemlink.path = Replace ("" "& Lnkitemlink.path &" "", Strtoreplace,strreplace)
Lnkitemlink.workingdirectory = Replace ("" "& Lnkitemlink.workingdirectory &" "", Strtoreplace,strreplace)
Lnkitemlink.save ()
End If
Next
For each subfolder in Folder.subfolders
' WScript.Echo ' Folder ' & Subfolder.path
Set Npfolder = Wshshell.namespace (Subfolder.path)
Set objfolder = Wshfso.getfolder (Subfolder.path)
Set allfiles = Objfolder.files
For each lnkfile in Allfiles
If InStrRev (UCase (Lnkfile.name), ". LNK ") <> 0 Then ' extension shortcuts
Set Lnkitem = Npfolder.parsename (lnkfile.name)
Set Lnkitemlink = Lnkitem.getlink
' WScript.Echo ' "" &lnkItemLink.Path& "" "
Lnkitemlink.path = Replace ("" "& Lnkitemlink.path &" "", Strtoreplace,strreplace)
Lnkitemlink.workingdirectory = Replace ("" "& Lnkitemlink.workingdirectory &" "", Strtoreplace,strreplace)
Lnkitemlink.save ()
End If
Next
Altersubfolders subfolder
Next
End Sub