Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the VBS scripts that bulk replace the shortcut destination path

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report