This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
win:icon_location_backup [2018/07/13 17:27] derek created |
win:icon_location_backup [2024/09/22 19:51] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| =====Icon Location Backup===== | =====Icon Location Backup===== | ||
| + | [[https:// | ||
| - | Backs up desktop icon locations to RB1.reg and RB2.reg in the same dir as this batch file | + | ====Setup==== |
| - | + | * Download [[https:// | |
| - | Download file and place in its own folder and add a shortcut | + | * Right-click |
| - | + | * Optionally, Right-Click the startup shortcut | |
| - | <code batch Desktop Icon Backup.bat> | + | |
| - | @echo off | + | |
| - | rem Backs up desktop icon locations to RB1.reg and RB2.reg in the same dir as this batch file | + | |
| - | rem automatically replacing the older .reg file with the current locations if they have changed | + | |
| - | rem Icon locations are only updated in the registry when explorer.exe closes gracefully | + | |
| - | rem To close explorer manually you can ctrl+shift+right-click the taskbar and click exit explorer | + | |
| - | rem Or restart it in the task manager | + | |
| - | + | ||
| - | rem Works well running on startup, just create a shortcut | + | |
| - | + | ||
| - | rem To recover: | + | |
| - | rem Open the wanted .reg file, likely the older one if the computer has restarted since the unwanted location change | + | |
| - | rem Don't yet respond to the confirmation dialogue. Don't worry if you already did, just open the .reg file again | + | |
| - | rem Close explorer manually: ctrl+shift+right-click the taskbar and click exit explorer | + | |
| - | rem Now click yes on the .reg file confirmation | + | |
| - | rem | + | |
| - | rem Type " | + | |
| - | rem The icon locations should now be recovered | + | |
| - | + | ||
| - | rem Tested on Win 10 | + | |
| - | + | ||
| - | setlocal ENABLEDELAYEDEXPANSION | + | |
| - | + | ||
| - | set _File1=" | + | |
| - | set _File2=" | + | |
| - | set _Curr=" | + | |
| - | + | ||
| - | rem Get the current, as of last explorer restart, state of the icon locations | + | |
| - | reg EXPORT HKCU\Software\Microsoft\Windows\Shell\Bags\1\Desktop !_Curr! /Y>Nul | + | |
| - | rem Create file 1/file 2 if needed | + | |
| - | if not exist !_File1! copy /V !_Curr! !_File1! | + | |
| - | if not exist !_File2! copy /V !_Curr! !_File2! | + | |
| - | + | ||
| - | rem Compares the age of the .reg files | + | |
| - | for /F " | + | |
| - | if !_Comp! == 1 ( | + | |
| - | set _Newer=!_File1! | + | |
| - | set _Older=!_File2! | + | |
| - | ) else ( | + | |
| - | set _Newer=!_File2! | + | |
| - | set _Older=!_File1! | + | |
| - | ) | + | |
| - | + | ||
| - | rem Check whether | + | |
| - | fc !_Curr! !_Newer!> | + | |
| - | if !errorlevel! == 0 ( | + | |
| - | echo No change detected | + | |
| - | ) else if !errorlevel! == 1 ( | + | |
| - | echo Change detected, overwriting !_Older! | + | |
| - | copy /Y /V !_Curr! !_Older! | + | |
| - | ) else ( | + | |
| - | echo File error! | + | |
| - | ) | + | |
| - | + | ||
| - | timeout 10 | + | |
| - | </ | + | |