What are the VBS scripts that bulk replace the shortcut destination path
The main content of this article is to explain "what are the VBS scripts for replacing the destination path of shortcuts in batches". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what VBS scripts are available to replace the shortcut destination path in batch.
You can replace all shortcuts under the specified directory and its subdirectories, specify the path where the shortcuts are stored, the string to be replaced, and the string you want to replace, and then double-click to run.
The copy code is as follows:
On Error Resume Next
'replace the path to all shortcuts under a folder and its subfolders
The path to the strFolderPath= "D:\ Program Files\ TrueLaunchBar\ Shortcut\ File\ Style" shortcut
StrToReplace= "\ SOFTWARE\" string that is replaced by a ring
The string replaced by strReplace= "\ [Software]\"
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
Whether the If InStrRev (UCase (lnkFile.Name), ".LNK") 0 Then 'extension is a shortcut
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
Whether the If InStrRev (UCase (lnkFile.Name), ".LNK") 0 Then 'extension is a shortcut
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
At this point, I believe you have a deeper understanding of "what batch replacement shortcut destination path VBS scripts". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!