相思资源网 Design By www.200059.com
可以替换指定目录及其子目录下所有的快捷方式,自己指定存放快捷方式的路径、要被替换的字符串和希望替换成的字符串,然后双击即可运行。
下面为代码,不很复杂,:)
复制代码 代码如下:On Error Resume Next
'替换某文件夹及其子文件夹下的所有快捷方式的指向路径
strFolderPath="D:\Program Files\TrueLaunchBar\Shortcut\File\ Style" '快捷方式的路径
strToReplace="\SOFTWARE\" '被替环的字符串
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
If InStrRev(UCase(lnkFile.Name), ".LNK") <> 0 Then '扩展名是否快捷方式
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 '扩展名是否快捷方式
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
下面为代码,不很复杂,:)
复制代码 代码如下:On Error Resume Next
'替换某文件夹及其子文件夹下的所有快捷方式的指向路径
strFolderPath="D:\Program Files\TrueLaunchBar\Shortcut\File\ Style" '快捷方式的路径
strToReplace="\SOFTWARE\" '被替环的字符串
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
If InStrRev(UCase(lnkFile.Name), ".LNK") <> 0 Then '扩展名是否快捷方式
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 '扩展名是否快捷方式
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
相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com
暂无批量替换快捷方式目的路径的VBS脚本的评论...