I wouldn't script it but here you have something to work with.
<pre>
Dim SearchFor : SearchFor = "\\OldServerName\"
Dim ReplaceWith : ReplaceWith = "\\NewServerName\"
Dim DirectoryPath : DirectoryPath = GetSpecialFolderPath("Desktop")
'Dim DirectoryPath : DirectoryPath = GetSpecialFolderPath("AllUsersDesktop")
EnumFolder DirectoryPath
Sub EnumFolder(DirectoryPath)
Dim FSO, Folder, Files, File, ShortcutPath, ShortcutTargetPath
Set FSO = CreateObject("Scripting.FileSystemObject")
If NOT FSO.FolderExists(DirectoryPath) Then Exit Sub
Set Folder = FSO.GetFolder(DirectoryPath) : Set Files = Folder.Files
For Each File in Files
If IsShortcut(File.Path) Then
ShortcutPath = File.Path
ShortcutTargetPath = GetShortcutTargetPath(File.Path)
If ValueMatchesSearchPattern(ShortcutTargetPath, SearchFor) Then
ShortcutTargetPath = GetNewShortcutTargetPath(ShortcutTargetPath)
Call SetShortcutTargetPath(ShortcutPath, ShortcutTargetPath)
End If
End If
Next
Set File = Nothing
Set Files = Nothing
Set Folder = Nothing
Set FSO = Nothing
End Sub
Function ValueMatchesSearchPattern(SearchValue, SearchPattern)
Dim i
ValueMatchesSearchPattern = False
If Instr(1, SearchValue, SearchPattern, 1) > 0 Then
ValueMatchesSearchPattern = True
End If
End Function
Function GetNewShortcutTargetPath(ShortcutTargetPath)
GetNewShortcutTargetPath = Replace(ShortcutTargetPath, SearchFor, ReplaceWith, 1, 1, 1)
End Function
Function IsShortcut(FilePath)
Dim FileExtension
IsShortcut = False
FileExtension = UCase(Mid(FilePath, InStrRev(FilePath, ".")+1))
If "LNK" = FileExtension Then IsShortcut = True
End Function
Function GetSpecialFolderPath(SpecialFolder)
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
GetSpecialFolderPath = WshShell.SpecialFolders(SpecialFolder)
Set WshShell = Nothing
End Function
Function GetShortcutTargetPath(ShortcutPath)
Dim WshShell, Shortcut
Set WshShell = CreateObject("WScript.Shell")
Set Shortcut = WshShell.CreateShortcut(ShortcutPath)
GetShortcutTargetPath = Shortcut.TargetPath
Set Shortcut = Nothing
Set WshShell = Nothing
End Function
Function SetShortcutTargetPath(ShortcutPath, ShortcutTargetPath)
Dim WshShell, Shortcut
Set WshShell = CreateObject("WScript.Shell")
Set Shortcut = WshShell.CreateShortcut(ShortcutPath)
Shortcut.TargetPath = ShortcutTargetPath
Shortcut.Save
Set Shortcut = Nothing
Set WshShell = Nothing
End Function
</pre>