Windows7のエクスプローラで出てくる「お気に入り」は、%USERPROFILE%\Links
というフォルダーにショートカットが全部並んでいる。
PowerShell を使って全部リネームしよう、そうしよう。
$fromName = "\\旧サーバ名\" $toName = "\\新サーバ名\" $wsh = New-Object -ComObject WScript.Shell Get-ChildItem (Join-Path $env:userprofile "Links") | %{ if( $_.Extension -eq ".lnk" ){ $shortcut = $wsh.CreateShortcut($_.FullName) $target = $shortcut.TargetPath if( $target.StartsWith($fromName) ){ $newTarget = $toName + $target.substring($fromName.Length) if( Test-Path $newTarget ){ Write-Output (" " + $target) Write-Output ("--> " + $newTarget) $shortcut.TargetPath = $newTarget $shortcut.Save() } } } }