$ show farag2/Sophia-Script-for-Windows
Sophia Script for Windows is a PowerShell-based system administration utility for fine-tuning Windows 10 and 11 installations. It provides over 150 configuration functions covering privacy, telemetry, UI personalization, security hardening, debloating, and system optimization. The tool is distributed as a PowerShell module with per-edition variants (Windows 10/11, LTSC, ARM, PowerShell 5.1/7) and includes a closed-source GUI wrapper (SophiaScriptWrapper.exe) for visual configuration. Architecture: The core is a PowerShell module (Sophia.psm1) with a preset file (Sophia.ps1) that users edit to select tweaks. The module loads private helper functions (Add-Policy, Get-Hash, WinAPI, etc.) and localization files. Execution flow: Import-TabCompletion.ps1 → InitialActions.ps1 (preflight checks) → user-selected tweaks → PostActions.ps1 (system refresh, toasts, restore points). The tool modifies Windows via registry keys, group policy (LGPO.exe), service management, scheduled tasks, and file association hashes. Key entry points: Sophia.ps1 (per edition) is the main preset; Import-TabCompletion.ps1 provides tab-completion; the Wrapper/ directory contains GUI config JSONs and the wrapper executable. External dependencies include LGPO.exe (Microsoft), WinRAR for packaging, and runtime downloads for HEVC codecs and cursor packs. The project is distributed via Chocolatey, WinGet, Scoop, and direct GitHub releases. Data flows: The script reads Windows build/version info, checks remote JSON manifests for updates, and applies changes based on user preset. It exports/imports file associations as JSON and creates restore points. Localization is handled via ConvertFrom-StringData .psd1 files in 12 languages. The tool is not a data pipeline or research project; it is a pure system configuration utility.
The LLM identified 4 files worth highlighting for reuse:
Encapsulates Windows API calls via embedded C# code compiled with Add-Type. Provides functions for extracting localized strings from shell32.dll, foreground window detection, cursor management, and environment refresh (SHChangeNotify/SendMessageTimeout). Demonstrates a reusable pattern for PowerShell-C# interop with error handling and type guards, isolated from the rest of the script.
Implements the patented 'UserChoice' file-association hash algorithm used by Windows to validate default application associations. Reverse-engineers the hash by extracting a secret string from shell32.dll, reading registry timestamps, and computing MD5 with a custom WordSwap cipher. This self-contained function can be extracted and reused in any PowerShell project that needs to programmatically set file associations without user prompts.
Provides an interactive console menu with arrow key navigation, localized Yes/No/Skip options, and configurable timeout. Uses WinAPI.GetStrings for native Windows button labels and supports default selection. The pattern is self-contained and reusable for any PowerShell script requiring user interaction in a terminal.
CI validation script that runs PSScriptAnalyzer, checks JSON validity, parses PSD1 localization files, and verifies key integrity across all language variants using PowerShell AST parsing. This pattern is reusable for any PowerShell project with multiple localization files and can be adapted for other CI pipelines.