网上找到的改变快捷方式的目标路径,可更改后,图标也变了,请问如何解决?
Sub Doit(strlnk)
Dim oShlnk
Set oShlnk = Wsh.CreateShortcut(strlnk)
If Instr(oShLnk.TargetPath,oldpath) > 0 Then
old=oShLnk.IconLocation
oShLnk.IconLocation=old '添加后无效
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
---------------------------------------------
oldpath = "这里填写原路径中将被替换的内容"
newpath = "这里填写新路径中要使用的内容"
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