Safely migrates hard-coded user paths (e.g. Users\geekybeaver) inside VS Code configuration, extensions, and state databases after moving to a new Windows user profile.
Designed for Windows 10/11 + PowerShell + sqlite3.
I had Windows 11 become corrupt, backups and restore points didn't work, the repair option didn't work, it just wouldn't boot into anything other than safe mode which was useless. I however imaged the old C drive as I had some important stuff on there.
Next I reinstalled Win 11 fresh, and am now copying over my VS Code config/extensions (yes I'm aware of the VS Sync feature already). The issue now is my Window user is different from my old C drive to my new C drive so I copied the config and extension folders over already and needed to update all old user path references
✅ Text files
- Scans VS Code user config and extensions
- Replaces:
Users\geekybeaverUsers/geekybeaver
- Writes back without corrupting encoding
- Preserves UTF-8 (with/without BOM), UTF-16 LE/BE
- Touches only whitelisted text extensions
- Creates a full backup of every modified file
✅ SQLite databases (VS Code state)
- Detects SQLite DBs safely
- Verifies DB is:
- SQLite
- Not locked
- Matches known VS Code schemas
- Targets VS Code state/storage DBs only (e.g.
state.vscdb,storage.db) - Updates TEXT columns only (never raw binary/BLOBs)
- Uses
sqlite3with transactions (BEGIN / COMMIT) - Backs up every DB before modification
- Skips unknown or incompatible databases
❌ What it will NOT do
- No blind binary search/replace
- No raw hex editing
- No touching random extension databases with unknown schemas
- No deleting caches or state files
- No modifying DBs that fail validation
- Windows 10 / 11
- PowerShell 5.1+
- sqlite3 on PATH
Install via
winget install SQLite.SQLite
- Close VS Code completely
- Make sure the source paths actually exist (e.g. old username appears somewhere)
- Run PowerShell normally (Admin is fine but not required)
C:\Users\<NewUser>\AppData\Roaming\Code
C:\Users\<NewUser>\.vscode\extensionsC:\Users\<NewUser>\AppData\Roaming\CodeEvery changed file or DB is copied to:
C:\temp\vscode-autofix-backups-<timestamp>\
Filenames are path-encoded to avoid collisions.
C:\temp\vscode-autofix-<timestamp>.log
The log includes:
- each modified file
- backup location
- skipped DBs
- errors (if any)
If the script reports DB errors or skips, that does NOT mean corruption.
The script only modifies a DB after:
- confirming it’s SQLite
- confirming expected tables exist
- successfully starting a transaction
Run this on any VS Code DB you’re unsure about:
sqlite3 "C:\path\to\state.vscdb" "PRAGMA quick_check;"Expected output:
ok
If you get ok, the DB is healthy.
After the script completes, verify there are no remaining references to the old username.
PowerShell verification scan
Get-ChildItem @(
"C:\Users\<NewUser>\AppData\Roaming\Code",
"C:\Users\<NewUser>\.vscode\extensions"
) -Recurse -File -Force -ErrorAction SilentlyContinue |
Select-String -Pattern "Users\\geekybeaver" -SimpleMatch -ErrorAction SilentlyContinue |
Select-Object Path, LineNumber- No output -> migration is clean
- Any hits shown -> inspect manuallly (often cache/state)
Text: Changed > 0= Expected, paths were fixedDB: Updated = 0= Normal if DBs didn't contain matching pathsDB: Skipped > 0= Normal - DB didn't match known schemaDB: Errors > 0= Ususally comand-level failure, not corruption
To restore any file or DB:
- Locate it in the backup directory
- Copy it back to over the original
- Restart VS Code.
No global rollback needed — backups are per-file.
- Encoding-aware writes (no
Set-Contentcorruption) - No dynamic SQL string building
- No blind binary edits
- Explicit schema checks
- Transaction-based DB updates
- Conservative skip-first behavior
Public domain / use at your own risk. Tested against real VS Code profiles with large extension sets.