Last active
November 27, 2025 09:55
-
-
Save themaximax/bffc0fa4403d61c7889157dd6e9f037b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $old = "\\terminal-pf\" | |
| $new = "\\agrohold.ru\pf\" | |
| $paths = @( | |
| "C:\Users\*\Desktop", | |
| "C:\Users\*\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar", | |
| "C:\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu", | |
| "C:\ProgramData\Microsoft\Windows\Start Menu" | |
| ) | |
| $updatedCount = 0 | |
| $shell = New-Object -ComObject WScript.Shell | |
| foreach ($path in $paths) { | |
| Get-ChildItem -Path $path -Filter *.lnk -Recurse -ErrorAction SilentlyContinue | ForEach-Object { | |
| $shortcut = $shell.CreateShortcut($_.FullName) | |
| if ($shortcut.TargetPath -like "*$old*") { | |
| $shortcut.TargetPath = $shortcut.TargetPath -replace [regex]::Escape($old), $new | |
| $shortcut.WorkingDirectory = $shortcut.WorkingDirectory -replace [regex]::Escape($old), $new | |
| $shortcut.Save() | |
| $updatedCount++ | |
| Write-Host "Updated: $($_.FullName)" | |
| } | |
| } | |
| } | |
| Write-Host "===============================" | |
| Write-Host "Total shortcuts updated: $updatedCount" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment