Tuesday, July 7, 2009

KiXtart: Update Desktop Shortcuts


Break ON

$oldPath = "\\server1\shareName1"
$newPath = "\\server2\shareName2"

$shell = CreateObject("WScript.Shell")
$DesktopPath = ExpandEnvironmentVars("%userprofile%")+"\Desktop"

$FileName = Dir("$DesktopPath\*.lnk")
While $FileName <> "" And @error = 0
? $FileName
$link = $shell.CreateShortcut("$DesktopPath\$FileName")
If Ucase($link.TargetPath) = Ucase($oldPath)
$link.TargetPath = $newPath
$link.Save
EndIf
$FileName = Dir()
Loop

No comments:

Post a Comment