Problems with links and shortcuts quickly arise as soon as the paths change when migrating a file server. This article is about the links that users have placed on their desktops. These could show files or links. If the hard disk structures change during a migration, then they stop functioning.
In environments where UNC-paths (ex.: \\server\share\directoryXY) are used as a direct path to the file server, we have found a way to minimize the problems for the end user, even if the paths are changed. It is common that end users have links on their desktops that show them the way to folders and documents on the servers. This document will introduce you to a simple script that replaces the paths for them.
This script is written in VBScript. The first lines define the old and new path.
strFind = “\\oldserver\share1\”
strReplace = “\\newserver\share2\”
Set objWsh = CreateObject(“WScript.Shell”)
Set objWshSysEnv = objWsh.Environment(“PROCESS”)
strProfilePath = objWshSysEnv(“USERPROFILE”)
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objFolder = objFSO.GetFolder(strProfilePath & “\Desktop”)
‘Loop through all files on the desktop
For Each file In objFolder.Files
if right(file.Name,3)=“lnk” then
‘If a shortcut is found
Set objLink = objWsh.CreateShortcut(file.Path)
objLink.Arguments = Replace(objLink.Arguments,strFind,strReplace,1,-1,1)
objLink.TargetPath = Replace(objLink.TargetPath,strFind,strReplace,1,-1,1)
objLink.WorkingDirectory = Replace(objLink.WorkingDirectory,strFind,strReplace,1,-1,1)
Include this script in your login script and you will have fewer problems after your file server-migration.