Option Explicit

Dim oldpath,newpath

''''''''''''''''说明'''''''''''''''''

'作用:批量修改快捷方式的“目标”和“起始位置”

'使用方法:和需要修改的快捷方式放在同一个文件夹执行

'''''''''''''''说明完'''''''''''''''''

oldpath = D:\netgame1 '设置原路径中将被替换的内容

newpath = G:\langame '设置新路径中要使用的内容

Dim Wsh,fso

Set Wsh = WScript.CreateObject(WScript.Shell)

Set fso = CreateObject(Scripting.FileSystemObject)

Dim ji_1,ji_2,Folder

ji_1 = 0

ji_2 = 0

Folder = Wsh.CurrentDirectory

if Ask(将要修改&chr(34)& Folder &chr(34)&里的所有快捷方,是否继续) then

Dim f,fc,f1,ext

Set f = fso.GetFolder(Folder)

Set fc = f.Files

For Each f1 in fc

ext = LCase(fso.GetExtensionName(f1))

if ext = lnk then

ji_1 = ji_1 + 1

call Doit(f1)

end if

Next

end if

Set WSH = Nothing

msgbox 找到 &ji_1& 个快捷方式&vbCrLf&修改 &ji_2& 个快捷方式,64,执行完毕

WScript.quit

Sub Doit(strlnk)

Dim oShlnk

Set oShlnk = Wsh.CreateShortcut(strlnk)

If Instr(oShLnk.TargetPath,oldpath) 0 Then

oShLnk.TargetPath = Replace(oShLnk.TargetPath,oldpath,newpath)

oShLnk.WorkingDirectory = Replace(oShLnk.WorkingDirectory,oldpath,newpath)

oShLnk.Save

ji_2 = ji_2 + 1

End If

Set oShLnk=NoThing

End Sub

Function Ask(strAction)

Dim intButton

intButton = MsgBox(strAction,vbQuestion + vbYesNo,询问)

Ask = intButton = vbYes

End Function

注意:把以上的文本复制到文本文档,另存为*.vbs即可

楼主注意看清楚怎么用,不明白继续问我

取消

评论

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐