可以替换指定目录及其子目录下所有的快捷方式,自己指定存放快捷方式的路径、要被替换的字符串和希望替换成的字符串,然后双击即可运行。
下面为代码,不很复杂,:)
复制代码 代码如下:OnErrorResumeNext
'替换某文件夹及其子文件夹下的所有快捷方式的指向路径
strFolderPath="D:ProgramFilesTrueLaunchBarShortcutFileStyle"'快捷方式的路径
strToReplace="SOFTWARE"'被替环的字符串
strReplace="[Software]"'替换成的字符串
SetwshShell=CreateObject("Shell.Application")
SetwshFSO=CreateObject("Scripting.FileSystemObject")
AlterSubFolderswshFSO.GetFolder(strFolderPath)
SubAlterSubFolders(Folder)
SetnpFolder=wshShell.Namespace(Folder.Path)
SetallFiles=Folder.Files
ForEachlnkFileInallFiles
'Wscript.EcholnkFile.Name
IfInStrRev(UCase(lnkFile.Name),".LNK")<>0Then'扩展名是否快捷方式
SetlnkItem=npFolder.ParseName(lnkFile.Name)
SetlnkItemLink=lnkItem.GetLink
'Wscript.Echo""""&lnkItemLink.Path&""""
lnkItemLink.Path=Replace(""""&lnkItemLink.Path&"""",strToReplace,strReplace)
lnkItemLink.WorkingDirectory=Replace(""""&lnkItemLink.WorkingDirectory&"""",strToReplace,strReplace)
lnkItemLink.Save()
EndIf
Next
ForEachSubfolderinFolder.SubFolders
'Wscript.Echo"Folder"&Subfolder.Path
SetnpFolder=wshShell.Namespace(Subfolder.Path)
SetobjFolder=wshFSO.GetFolder(Subfolder.Path)
SetallFiles=objFolder.Files
ForEachlnkFileinallFiles
IfInStrRev(UCase(lnkFile.Name),".LNK")<>0Then'扩展名是否快捷方式
SetlnkItem=npFolder.ParseName(lnkFile.Name)
SetlnkItemLink=lnkItem.GetLink
'Wscript.Echo""""&lnkItemLink.Path&""""
lnkItemLink.Path=Replace(""""&lnkItemLink.Path&"""",strToReplace,strReplace)
lnkItemLink.WorkingDirectory=Replace(""""&lnkItemLink.WorkingDirectory&"""",strToReplace,strReplace)
lnkItemLink.Save()
EndIf
Next
AlterSubFoldersSubfolder
Next
EndSub