{"id":18852727,"url":"https://github.com/tatsh/winprefs","last_synced_at":"2025-04-14T10:21:24.235Z","repository":{"id":198824997,"uuid":"701625794","full_name":"Tatsh/winprefs","owner":"Tatsh","description":"Tool to export registry paths to script and code formats (reg add, PowerShell, C, C#).","archived":false,"fork":false,"pushed_at":"2025-03-31T11:26:41.000Z","size":1669,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T03:59:50.668Z","etag":null,"topics":["backup","batch","c","csharp","customisation","customization","desktop","powershell","registry","win32","windows"],"latest_commit_sha":null,"homepage":"https://tatsh.github.io/winprefs/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Tatsh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Tatsh","patreon":"tatsh2","ko_fi":"tatsh2","liberapay":"tatsh2"}},"created_at":"2023-10-07T05:09:11.000Z","updated_at":"2025-03-31T11:26:41.000Z","dependencies_parsed_at":"2023-12-11T23:42:11.157Z","dependency_job_id":"25e361ef-14a3-40e1-b36d-c8502777b678","html_url":"https://github.com/Tatsh/winprefs","commit_stats":null,"previous_names":["tatsh/winprefs"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fwinprefs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fwinprefs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fwinprefs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Tatsh%2Fwinprefs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Tatsh","download_url":"https://codeload.github.com/Tatsh/winprefs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248860006,"owners_count":21173344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","batch","c","csharp","customisation","customization","desktop","powershell","registry","win32","windows"],"created_at":"2024-11-08T03:41:18.413Z","updated_at":"2025-04-14T10:21:24.188Z","avatar_url":"https://github.com/Tatsh.png","language":"C","funding_links":["https://github.com/sponsors/Tatsh","https://patreon.com/tatsh2","https://ko-fi.com/tatsh2","https://liberapay.com/tatsh2"],"categories":[],"sub_categories":[],"readme":"# winprefs\n\n[![Build](https://github.com/Tatsh/winprefs/actions/workflows/cmake.yml/badge.svg)](https://github.com/Tatsh/winprefs/actions/workflows/cmake.yml)\n[![Tests](https://github.com/Tatsh/winprefs/actions/workflows/tests.yml/badge.svg)](https://github.com/Tatsh/winprefs/actions/workflows/tests.yml)\n[![Coverage Status](https://coveralls.io/repos/github/Tatsh/winprefs/badge.svg?branch=master)](https://coveralls.io/github/Tatsh/winprefs?branch=master)\n[![QA](https://github.com/Tatsh/winprefs/actions/workflows/qa.yml/badge.svg)](https://github.com/Tatsh/winprefs/actions/workflows/qa.yml)\n[![CodeQL](https://github.com/Tatsh/winprefs/actions/workflows/codeql.yml/badge.svg)](https://github.com/Tatsh/winprefs/actions/workflows/codeql.yml)\n[![PowerShell Gallery Version (including pre-releases)](https://img.shields.io/powershellgallery/v/WinPrefs)](https://www.powershellgallery.com/packages/WinPrefs)\n[![PowerShell Gallery Platform Support](https://img.shields.io/powershellgallery/p/WinPrefs?label=powershell+platforms+supported)](https://www.powershellgallery.com/packages/WinPrefs)\n![GitHub tag (with filter)](https://img.shields.io/github/v/tag/Tatsh/winprefs)\n![GitHub](https://img.shields.io/github/license/Tatsh/winprefs)\n![GitHub commits since latest release (by SemVer including pre-releases)](https://img.shields.io/github/commits-since/Tatsh/winprefs/v0.3.2/master)\n\nmacOS users: please see [macprefs](https://github.com/Tatsh/macprefs) for an equivalent tool.\n\nThis package dumps a registry path to equivalent `reg` commands. It contains two commands.\n`Save-Preferences` creates a batch script composed of `reg` commands for copying into a script.\n`Write-RegCommands` is effectively the same but requires a path argument and only writes to standard\noutput.\n\nBy default both commands default to a maximum depth of 20. `Save-Preferences` defaults to path\n`HKCU:`.\n\nNote that by default only `HKCU:` and `HKLM:` are mounted in PowerShell. Others need to be mounted\nand must be under the appropriate name such as `HKU` for `HKEY_USERS`.\n\nKeys/values are skipped under these conditions:\n\n- Depth limit (default: 20); this can be changed by passing `-MaxDepth LIMIT` or `-m LIMIT`\n- Key that cannot be read for any reason such as permissions\n- Value contains newlines\n- Value has type `REG_UNKNOWN`\n\nAn example of an always skipped key under normal circumstances is `HKLM\\SECURITY`, even if this is\nrun as administrator.\n\nWARNING: If you save an entire tree such as `HKLM:` to a file and attempt to run said script, you\nprobably will break your OS. The output of this tool is meant for getting a single command at a\ntime, testing it, and then using it in an appropriate script. The author will not be held\nresponsible for any damages.\n\n## Installation\n\n```powershell\nInstall-Module -Name WinPrefs\n```\n\n## Usage\n\n```powershell\nSave-Preferences\n# or the alias:\nprefs-export\n```\n\n`Save-Preferences` generates an `exec-reg.bat` (default name) file and saves to\n`${env:APPDATA}\\prefs-export` by default. This can be changed by passing `-OutputDirectory DIR`\n(or `-o DIR`). The file name can be changed by passing `-OutputFile FILE` (or `-f FILE`).\n\nThe format can be changed with the `-Format` argument. Accepted format strings:\n\n-\n\nIt accepts switch `-Commit`/`-c` to initialise and commit to a Git repository in the output\ndirectory. It also accepts a `-DeployKey PATH` parameter and will push if this is specified. Any\nother Git management such as the branch name, etc must be managed in the output directory manually.\n\n```powershell\nWrite-RegCommands HKCU:\n# or the alias\npath2reg HKCU:\n```\n\n`Write-RegCommands` prints out equivalent reg commands to reproduce the keys/values at the given\npath. `reg` command output is escaped for Batch file only. No variables will be present in the\noutput. If you want to use a `reg` command in PowerShell you need to replace `%%` with `%`.\n\n## Automated Usage\n\nYou can create a scheduled task that will run every 12 hours to backup a registry path.\n`Register-SavePreferencesScheduledTask` (`winprefs-install-job`) can be called multiple times with\ndifferent `-Path` arguments. Like `Save-Preferences` it can automatically commit to a repository and\npush.\n\nCalling `Register-SavePreferencesScheduledTask` multiple times with the same `-Path` argument will\nnot break anything. If a task with the same name already exists, it must be unregistered before its\nreplacement can be made.\n\nAny task can be uninstalled with `Unregister-SavePreferencesScheduledTask` (`winprefs-uninstall-job`)\nwith the same `-Path` argument.\n\n### Examples\n\n#### Save `HKEY_LOCAL_MACHINE\\Control Panel` with a depth of 1\n\n```powershell\nprefs-export -o . -m 1 -Path 'HKCU:\\Control Panel\\Desktop'\ncat exec-reg.bat\n```\n\nOutput:\n\n```batch\nreg add \"HKCU\\Control Panel\\Desktop\\Colors\" /v \"ActiveBorder\" /t REG_SZ /d \"212 208 200\" /f\nreg add \"HKCU\\Control Panel\\Desktop\\Colors\" /v \"ActiveTitle\" /t REG_SZ /d \"10 36 106\" /f\nREM ...\n```\n\n### Export, commit with Git and push with a key\n\n#### Dump WindowMetrics as C code\n\n```powershell\nWrite-RegCommands HKCU:\\Environment -Format c\n```\n\nOutput:\n\n```c\ndata = { 0xee, 0xff, 0xff, 0xff, /* ... */}; RegSetKeyValue(HKEY_CURRENT_USER, TEXT(\"Control Panel\\\\Desktop\\\\WindowMetrics\"), TEXT(\"CaptionFont\"), REG_BINARY, (LPCVOID)\u0026data, 92);\n```\n\n#### Dump a single value\n\n```powershell\nWrite-RegCommands HKCU:\\Environment\\OneDrive\n```\n\nOutput:\n\n```batch\nreg add \"HKCU\\Environment\\OneDrive\" /v \"OneDrive\" /t REG_EXPAND_SZ /d \"%%USERPROFILE%%\\OneDrive\" /f\n```\n\n#### Dump a binary value\n\n```powershell\nWrite-RegCommands 'HKCU:\\Control Panel\\Desktop\\WindowMetrics\\StatusFont'\n```\n\nOutput:\n\n```batch\nreg add \"HKCU\\Control Panel\\Desktop\\WindowMetrics\\StatusFont\" /v \"StatusFont\" /t REG_BINARY /d 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b /f\n```\n\n## Native version\n\nThe PowerShell module makes use of the native code with `DllImport` to get a significant speed\nincrease in making registry queries and performing I/O. A native binary `winprefs.exe` can also be\nbuilt that can be used without needing PowerShell installed and it should work with XP and newer. If\nbuilt as a a 32-bit binary, the native binary should be compatible with Windows 2000 and newer. It\neven works with Wine.\n\nUsage is similar to the PowerShell version:\n\n```plain\nUsage: winprefs.exe [OPTION...] [REG_PATH]\n\nIf a path to a value name is specified, the output directory argument is ignored and the line is\nprinted to standard output.\n\nOptions:\n  -F, --format=FORMAT Format to output. Options: c, cs, c#, ps, ps1, powershell, reg. Default: reg.\n  -K, --deploy-key    Deploy key for committing.\n  -c, --commit        Commit changes.\n  -d, --debug         Enable debug logging.\n  -f, --output-file   Output filename.\n  -m, --max-depth=INT Set maximum depth.\n  -o, --output-dir    Output directory.\n  -h, --help          Display this help and exit.\n```\n\nNote the equivalent format names (case-insensitive):\n\n- C#: `cs`, `c#`\n- PowerShell: `ps`, `ps1`, `powershell`\n\n## Development\n\nRequirements:\n\n- Windows\n- Yarn\n\n### Building\n\n#### Visual Studio\n\nOn Windows with Visual Studio installed:\n\n```shell\nmkdir build\ncd build\ncmake -Wno-dev ..\ncmake -G 'Visual Studio 17 2022' --build . -DCMAKE_BUILD_TYPE=Release\ncmake --build . --config Release\n```\n\nUsing the VS developer environment shell is not required but it may help.\n\nAfter building `winprefs.exe` will be in `build\\native\\Release\\winprefs.exe`.\n\n#### MinGW\n\nNote: The PowerShell module (C# code) is only buildable with Visual Studio 2022.\n\n```shell\nmkdir build\ncd build\ncmake -G Ninja -Wno-dev ..\ncmake --build . --config Release --verbose\n```\n\nAfter building `winprefs.exe` will be in `build/native/winprefs.exe`.\n\n#### Cross-compiling\n\n```shell\nmkdir build\ncd build\ncmake -G Ninja -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_C_COMPILER=/usr/lib/mingw64-toolchain/bin/x86_64-w64-mingw32-gcc -DCMAKE_SYSTEM_NAME=Windows -Wno-dev ..\ncmake --build . --config Release --verbose\n```\n\nYou may need to adjust paths above.\n\nAfter building `winprefs.exe` will be in `build/native/winprefs.exe`.\n\n### Tasks\n\n- `yarn format`: to format the project's files.\n- `yarn qa`: Perform a QA check.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftatsh%2Fwinprefs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftatsh%2Fwinprefs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftatsh%2Fwinprefs/lists"}