# How to read/edit `store.dat` on Windows ## What this does - Decrypts `%AppData%\rIDE\\store.dat` using Windows **DPAPI (CurrentUser)**. - Lets you **view** keys and **update** a value (e.g., `GithubToken`, `SupabaseToken`, etc.). - Must be run **as the same Windows user account** that created the file. ------------------------------------------------------------------------ ## 0) One-time setup 1. **Save the script** (name it exactly): `decrypt-dat-file.ps1`\ (Use the version Jimmy shared --- it already loads the `System.Security` assembly and includes `Set-StoreValue`.) 2. Put it somewhere easy, e.g.: C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1 ------------------------------------------------------------------------ ## 1) Open PowerShell & allow running the script (this session only) ``` powershell Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass ``` ------------------------------------------------------------------------ ## 2) Find your `userId` folder and back up the file `store.dat` lives at: %AppData%\rIDE\\store.dat In PowerShell, reference `%AppData%` as `$env:APPDATA`. Example: ``` powershell # Replace with the actual folder name (GUID) cd "$env:APPDATA\rIDE\" Copy .\store.dat .\store.bak ``` > Tip: to list the available userId folders: ``` powershell Get-ChildItem "$env:APPDATA\rIDE" ``` ------------------------------------------------------------------------ ## 3) List keys / read values (no edits yet) ### Option A --- run the script with parameters (no functions loaded) Use the **call operator** `&` when passing parameters: ``` powershell & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -ListKeys # Example output: GithubToken, SupabaseToken, AzureAccessToken, ... ``` Read a specific key: ``` powershell & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -Key GithubToken -Raw ``` > `-Raw` prints the exact string. Without `-Raw`, JSON values (like > `SupabaseToken`) are pretty-printed. ------------------------------------------------------------------------ ## 4) Edit a value You have **two ways** to edit: ### Option A (recommended): *dot-source* once, then call `Set-StoreValue` Dot-sourcing loads the helper functions into your shell: ``` powershell . "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" ``` Now update a key: - **Plain string key** (e.g., `GithubToken`): ``` powershell Set-StoreValue -UserId "" -Key "GithubToken" -Value "ghp_or_ghu_yourNewTokenHere" ``` - **JSON key** (e.g., `SupabaseToken` expects JSON): ``` powershell $newPat = '{"AccessToken":"myNewSupabasePAT","RefreshToken":null,"ExpiresAt":"2025-12-31T23:59:59Z"}' Set-StoreValue -UserId "" -Key "SupabaseToken" -Value $newPat ``` Verify: ``` powershell & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -Key GithubToken -Raw # or & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -Key SupabaseToken ``` ### Option B: stay "no functions" and only run the script Use this only to **view** or **list**; editing requires Option A. ------------------------------------------------------------------------ ## 5) Common pitfalls & fixes - **`The term 'Set-StoreValue' is not recognized`**\ You *ran* the script but didn't dot-source it. Dot-source first: ``` powershell . "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" ``` - **`Unable to find type [System.Security.Cryptography.ProtectedData]`**\ Use the script Jimmy provided (it includes `Add-Type -AssemblyName System.Security`).\ If you still see it: ``` powershell Add-Type -AssemblyName System.Security ``` - **`DPAPI Unprotect failed...`**\ You're not running as the same Windows user that created the file. Switch to that user profile. - **`%AppData%` doesn't work in PowerShell**\ Use `$env:APPDATA` (PowerShell style): ``` powershell cd "$env:APPDATA\rIDE\" ``` - **Edited value shape** - Keys like `GithubToken` are **plain strings**.\ - Keys like `SupabaseToken` and `projectSecret_*` are **JSON**. Make sure you pass valid JSON. ------------------------------------------------------------------------ ## 6) Quick examples (ready to paste) ### List keys ``` powershell & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -ListKeys ``` ### Read GitHub token (raw) ``` powershell & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -Key GithubToken -Raw ``` ### Update GitHub token ``` powershell . "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" Set-StoreValue -UserId "" -Key "GithubToken" -Value "ghp_or_ghu_yourNewTokenHere" ``` ### Update Supabase token (JSON) ``` powershell . "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" $newPat = '{"AccessToken":"myNewSupabasePAT","RefreshToken":null,"ExpiresAt":"2025-12-31T23:59:59Z"}' Set-StoreValue -UserId "" -Key "SupabaseToken" -Value $newPat ``` ### Verify ``` powershell & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -Key GithubToken -Raw & "C:\Users\\OneDrive\Desktop\Codebuddy\decrypt-dat-file.ps1" -UserId "" -Key SupabaseToken ```