diff --git a/Cargo.lock b/Cargo.lock index 6ff8e23..f7d2172 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "W11Boost" -version = "1.4.0" +version = "1.4.1" dependencies = [ "chrono", "curl", diff --git a/Cargo.toml b/Cargo.toml index 102cecd..865dfe8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "W11Boost" -version = "1.4.0" +version = "1.4.1" edition = "2024" build = "build.rs" authors = ["felikcat"] @@ -8,11 +8,11 @@ authors = ["felikcat"] [package.metadata.winres] CompanyName = "felikcat" FileDescription = "https://github.com/felikcat/W11Boost" -FileVersion = "1.4.0.0" +FileVersion = "1.4.1.0" LegalCopyright = "© 2024 felikcat, AGPL3 License" OriginalFilename = "W11Boost.exe" ProductName = "W11Boost" -ProductVersion = "1.4.0.0" +ProductVersion = "1.4.1.0" # Optimize for size. [profile.release] diff --git a/src/gui/defaults.rs b/src/gui/defaults.rs index c7d7118..b0285ca 100644 --- a/src/gui/defaults.rs +++ b/src/gui/defaults.rs @@ -4,84 +4,82 @@ use std::{ fs::{self, File}, process::Command, }; -use windows::{core::w, Win32::System::{GroupPolicy::IGroupPolicyObject, Registry::{HKEY, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE}}}; -use winsafe::{co::FILE_ATTRIBUTE, prelude::advapi_Hkey, SetFileAttributes, HKEY as HKEY_SAFE}; +use winsafe::{HKEY, SetFileAttributes, co::FILE_ATTRIBUTE, prelude::advapi_Hkey}; pub fn run() -> Result<(), Box> { - let (hklm, gpo_hklm): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_LOCAL_MACHINE)?; - let (hkcu, gpo_hkcu): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_CURRENT_USER)?; - let hklm_safe = HKEY_SAFE::LOCAL_MACHINE; + let hklm = HKEY::LOCAL_MACHINE; + let hkcu = HKEY::CURRENT_USER; // If allowed (1): unused apps would be uninstalled with their user data left intact, then reinstalled if launched afterwards at any point in time. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Appx"), - w!("AllowAutomaticAppArchiving"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Appx", + "AllowAutomaticAppArchiving", 0, )?; // Make all users opted out of the Windows Customer Experience Improvement Program. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\SQMClient\Windows"), - w!("CEIPEnable"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\SQMClient\Windows", + "CEIPEnable", 0, )?; // Shows what's slowing down bootups and shutdowns. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"), - w!("verbosestatus"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", + "verbosestatus", 1, )?; // Ask to not allow execution of experiments by Microsoft. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\PolicyManager\current\device\System"), - w!("AllowExperimentation"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\PolicyManager\current\device\System", + "AllowExperimentation", 0, )?; // Power Throttling causes severe performance reduction for VMWare. // Workstation 17 - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Control\Power\PowerThrottling"), - w!("PowerThrottlingOff"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Control\Power\PowerThrottling", + "PowerThrottlingOff", 1, )?; // https://docs.microsoft.com/en-us/windows/desktop/win7appqual/fault-tolerant-heap // FTH being enabled causes issues with specific apps such as Assetto Corsa. - set_dword_gpo(hklm, w!(r"SOFTWARE\Microsoft\FTH"), w!("Enabled"), 0)?; + set_dword(&hklm, r"SOFTWARE\Microsoft\FTH", "Enabled", 0)?; // Automated file cleanup without user interaction is a bad idea, even if ran only on low-disk space events. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Appx"), - w!("AllowStorageSenseGlobal"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Appx", + "AllowStorageSenseGlobal", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\StorageSense"), - w!("AllowStorageSenseGlobal"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\StorageSense", + "AllowStorageSenseGlobal", 0, )?; remove_subkey( - &hklm_safe, + &hklm, r"SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense", )?; // Allocate more RAM to NTFS' paged pool. - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Policies"), - w!("NtfsForceNonPagedPoolAllocation"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Policies", + "NtfsForceNonPagedPoolAllocation", 1, )?; @@ -96,26 +94,26 @@ pub fn run() -> Result<(), Box> { .output()?; // Do not page drivers and other system code to a disk, keep it in memory. - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management"), - w!("DisablePagingExecutive"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management", + "DisablePagingExecutive", 1, )?; // Disables "Fast startup", a form of hibernation. - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Control\Session Manager\Power"), - w!("HiberbootEnabled"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Control\Session Manager\Power", + "HiberbootEnabled", 0, )?; // Do not require use of fast startup. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\System"), - w!("HiberbootEnabled"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\System", + "HiberbootEnabled", 0, )?; @@ -141,294 +139,294 @@ pub fn run() -> Result<(), Box> { .expect("SetFileAttributes 2 failed"); // Visual Studio 2017 up to 2022: PerfWatson2 (VSCEIP; telemetry) is intensive on resources, disable it. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Wow6432Node\Microsoft\VSCommon\15.0\SQM"), - w!("OptIn"), + set_dword( + &hklm, + r"SOFTWARE\Wow6432Node\Microsoft\VSCommon\15.0\SQM", + "OptIn", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Wow6432Node\Microsoft\VSCommon\16.0\SQM"), - w!("OptIn"), + set_dword( + &hklm, + r"SOFTWARE\Wow6432Node\Microsoft\VSCommon\16.0\SQM", + "OptIn", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Wow6432Node\Microsoft\VSCommon\17.0\SQM"), - w!("OptIn"), + set_dword( + &hklm, + r"SOFTWARE\Wow6432Node\Microsoft\VSCommon\17.0\SQM", + "OptIn", 0, )?; // Visual Studio: disable other telemetry. - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\VisualStudio\Telemetry"), - w!("TurnOffSwitch"), + set_dword( + &hkcu, + r"Software\Microsoft\VisualStudio\Telemetry", + "TurnOffSwitch", 1, )?; // Disable various forms of telemetry. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"), - w!("AllowTelemetry"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection", + "AllowTelemetry", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"), - w!("MaxTelemetryAllowed"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection", + "MaxTelemetryAllowed", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo"), - w!("DisabledByGroupPolicy"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo", + "DisabledByGroupPolicy", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\DataCollection"), - w!("AllowDeviceNameInTelemetry"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\DataCollection", + "AllowDeviceNameInTelemetry", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\DataCollection"), - w!("AllowTelemetry"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\DataCollection", + "AllowTelemetry", 0, )?; // Disable Services Configuration. // Used by Windows components and apps, such as the telemetry service, to dynamically update their configuration. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\DataCollection"), - w!("DisableOneSettingsDownloads"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\DataCollection", + "DisableOneSettingsDownloads", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\DataCollection"), - w!("DisableTelemetryOptInChangeNotification"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\DataCollection", + "DisableTelemetryOptInChangeNotification", 1, )?; // Disable "Connected User Experiences and Telemetry" service - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack"), - w!("ShowedToastAtLevel"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack", + "ShowedToastAtLevel", 1, )?; - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Services\DiagTrack"), - w!("Start"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Services\DiagTrack", + "Start", 4, )?; // Disable "Diagnostic Policy Service" // Logs tons of information to be sent off and analyzed by Microsoft, and in some cases caused noticeable performance slowdown. - set_dword_gpo(hklm, w!(r"SYSTEM\CurrentControlSet\Services\DPS"), w!("Start"), 4)?; + set_dword(&hklm, r"SYSTEM\CurrentControlSet\Services\DPS", "Start", 4)?; // Disable "Customer Experience Improvement Program"; also implies turning off the Inventory Collector. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\AppV\CEIP"), - w!("CEIPEnable"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\AppV\CEIP", + "CEIPEnable", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\SQMClient\Windows"), - w!("CEIPEnable"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\SQMClient\Windows", + "CEIPEnable", 0, )?; //--START-- Disable "Windows Error Reporting" service - let wer = w!(r"SOFTWARE\Microsoft\Windows\Windows Error Reporting"); - set_dword_gpo(hklm, wer, w!("Disabled"), 1)?; - set_dword_gpo(hklm, wer, w!("AutoApproveOSDumps"), 0)?; - set_dword_gpo(hklm, wer, w!("DefaultConsent"), 1)?; - set_dword_gpo(hklm, wer, w!("DefaultOverrideBehavior"), 0)?; - set_dword_gpo(hklm, wer, w!("DontSendAdditionalData"), 1)?; - set_dword_gpo(hklm, wer, w!("LoggingDisabled"), 1)?; - - let error_reporting = w!(r"SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting"); - set_dword_gpo(hklm, error_reporting, w!("AllOrNone"), 0)?; - set_dword_gpo(hklm, error_reporting, w!("IncludeKernelFaults"), 0)?; - set_dword_gpo(hklm, error_reporting, w!("IncludeMicrosoftApps"), 0)?; - set_dword_gpo(hklm, error_reporting, w!("IncludeShutdownErrs"), 0)?; - set_dword_gpo(hklm, error_reporting, w!("IncludeWindowsApps"), 0)?; - set_dword_gpo(hklm, error_reporting, w!("DoReport"), 0)?; - - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Settings"), - w!("DisableSendGenericDriverNotFoundToWER"), + let wer = r"SOFTWARE\Microsoft\Windows\Windows Error Reporting"; + set_dword(&hklm, wer, "Disabled", 1)?; + set_dword(&hklm, wer, "AutoApproveOSDumps", 0)?; + set_dword(&hklm, wer, "DefaultConsent", 1)?; + set_dword(&hklm, wer, "DefaultOverrideBehavior", 0)?; + set_dword(&hklm, wer, "DontSendAdditionalData", 1)?; + set_dword(&hklm, wer, "LoggingDisabled", 1)?; + + let error_reporting = r"SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting"; + set_dword(&hklm, error_reporting, "AllOrNone", 0)?; + set_dword(&hklm, error_reporting, "IncludeKernelFaults", 0)?; + set_dword(&hklm, error_reporting, "IncludeMicrosoftApps", 0)?; + set_dword(&hklm, error_reporting, "IncludeShutdownErrs", 0)?; + set_dword(&hklm, error_reporting, "IncludeWindowsApps", 0)?; + set_dword(&hklm, error_reporting, "DoReport", 0)?; + + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Settings", + "DisableSendGenericDriverNotFoundToWER", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Settings"), - w!("DisableSendRequestAdditionalSoftwareToWER"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Settings", + "DisableSendRequestAdditionalSoftwareToWER", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting"), - w!("Disabled"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting", + "Disabled", 1, )?; - set_string_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting\ExcludedApplications"), - w!("*"), - w!("0"), + set_string( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting\ExcludedApplications", + "*", + "*", )?; - set_string_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting\ExclusionList"), - w!("*"), - w!("0"), + set_string( + &hklm, + r"SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting\ExclusionList", + "*", + "*", )?; - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Services\WerSvc"), - w!("Start"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Services\WerSvc", + "Start", 4, )?; remove_subkey( - &hklm_safe, + &hklm, r"SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting\InclusionList", )?; remove_subkey( - &hklm_safe, + &hklm, r"SOFTWARE\Policies\Microsoft\PCHealth\ErrorReporting\Consent", )?; //--END-- Disable "Windows Error Reporting" service // Disable telemetry for Tablet PC's handwriting recognition - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\TabletPC"), - w!("PreventHandwritingDataSharing"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\TabletPC", + "PreventHandwritingDataSharing", 1, )?; // Disable feedback reminders. - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Windows\DataCollection"), - w!("DoNotShowFeedbackNotifications"), + set_dword( + &hklm, + r"Software\Policies\Microsoft\Windows\DataCollection", + "DoNotShowFeedbackNotifications", 1, )?; - set_dword_gpo( - hkcu, - w!(r"SOFTWARE\Microsoft\Siuf\Rules"), - w!("NumberOfSIUFInPeriod"), + set_dword( + &hkcu, + r"SOFTWARE\Microsoft\Siuf\Rules", + "NumberOfSIUFInPeriod", 0, )?; - set_dword_gpo( - hkcu, - w!(r"SOFTWARE\Microsoft\Siuf\Rules"), - w!("PeriodInNanoSeconds"), + set_dword( + &hkcu, + r"SOFTWARE\Microsoft\Siuf\Rules", + "PeriodInNanoSeconds", 0, )?; // Ask OneDrive to only generate network traffic if signed in to OneDrive - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\OneDrive"), - w!("PreventNetworkTrafficPreUserSignIn"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\OneDrive", + "PreventNetworkTrafficPreUserSignIn", 1, )?; // Don't ask to change the current privacy settings after applying a major // Windows update - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\OOBE"), - w!("DisablePrivacyExperience"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\OOBE", + "DisablePrivacyExperience", 1, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo"), - w!("Enabled"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo", + "Enabled", 0, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy"), - w!("HasAccepted"), + set_dword( + &hkcu, + r"Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy", + "HasAccepted", 0, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\InputPersonalization"), - w!("RestrictImplicitInkCollection"), + set_dword( + &hkcu, + r"Software\Microsoft\InputPersonalization", + "RestrictImplicitInkCollection", 1, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\InputPersonalization"), - w!("RestrictImplicitTextCollection"), + set_dword( + &hkcu, + r"Software\Microsoft\InputPersonalization", + "RestrictImplicitTextCollection", 1, )?; // Don't send Microsoft inking and typing data to "improve suggestions". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput"), - w!("AllowLinguisticDataCollection"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput", + "AllowLinguisticDataCollection", 0, )?; // Disable SmartScreen's Enhanced Phishing Protection; it's akin to Microsoft's Recall functionality. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\WTDS\Components"), - w!("ServiceEnabled"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\WTDS\Components", + "ServiceEnabled", 0, )?; // Disable the language list fingerprinting method; useful for bypassing geolocation restrictions. - set_dword_gpo( - hkcu, - w!(r"Control Panel\International\User Profile"), - w!("HttpAcceptLanguageOptOut"), + set_dword( + &hkcu, + r"Control Panel\International\User Profile", + "HttpAcceptLanguageOptOut", 1, )?; // Enable multiple processes for explorer.exe for increased stability and performance. - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"), - w!("SeparateProcess"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", + "SeparateProcess", 1, )?; // Hidden file extensions are abused to hide the real file format, example: // an executable (.exe, .scr, .com) pretending to be a PDF. - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"), - w!("HideFileExt"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", + "HideFileExt", 0, )?; // Allow usage of some .appx/.appxbundle apps without a Microsoft account. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"), - w!("MSAOptional"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", + "MSAOptional", 1 )?; @@ -439,7 +437,5 @@ pub fn run() -> Result<(), Box> { "Set-NetAdapterAdvancedProperty -Name '*' -DisplayName 'Wait for Link' -RegistryValue 0" ]).output().expect("Setting network adapter advanced property failed"); - save_registry_gpo(hklm, gpo_hklm)?; - save_registry_gpo(hkcu, gpo_hkcu)?; Ok(()) } diff --git a/src/gui/disable_sleep.rs b/src/gui/disable_sleep.rs index 4a3e8b5..9eecb55 100644 --- a/src/gui/disable_sleep.rs +++ b/src/gui/disable_sleep.rs @@ -1,99 +1,97 @@ use std::error::Error; -use windows::{core::w, Win32::System::{GroupPolicy::IGroupPolicyObject, Registry::{HKEY, HKEY_LOCAL_MACHINE}}}; +use winsafe::prelude::*; +use winsafe::HKEY; use crate::common::*; pub fn run() -> Result<(), Box> { - let (hklm, gpo_hklm): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_LOCAL_MACHINE)?; + let hklm = HKEY::LOCAL_MACHINE; - // Globally disable hibernation. - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Control\Power"), - w!("HibernateEnabledDefault"), + // Globally disable hibernation + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Control\Power", + "HibernateEnabledDefault", 0, )?; - // Turn off hybrid sleep (on battery). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\94ac6d29-73ce-41a6-809f-6363ba21b47e"), - w!("DCSettingIndex"), + // Turn off hybrid sleep (on battery) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\94ac6d29-73ce-41a6-809f-6363ba21b47e", + "DCSettingIndex", 0, )?; - // Turn off hybrid sleep (plugged in). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\94ac6d29-73ce-41a6-809f-6363ba21b47e"), - w!("ACSettingIndex"), + // Turn off hybrid sleep (plugged in) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\94ac6d29-73ce-41a6-809f-6363ba21b47e", + "ACSettingIndex", 0, )?; - // Never idle to sleep (on battery). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\29F6C1DB-86DA-48C5-9FDB-F2B67B1F44DA"), - w!("DCSettingIndex"), + // Never idle to sleep (on battery) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\29F6C1DB-86DA-48C5-9FDB-F2B67B1F44DA", + "DCSettingIndex", 0, )?; - // Never idle to sleep (plugged in). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\29F6C1DB-86DA-48C5-9FDB-F2B67B1F44DA"), - w!("ACSettingIndex"), + // Never idle to sleep (plugged in) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\29F6C1DB-86DA-48C5-9FDB-F2B67B1F44DA", + "ACSettingIndex", 0, )?; - // Never idle to hibernate (on battery). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\9D7815A6-7EE4-497E-8888-515A05F02364"), - w!("DCSettingIndex"), + // Never idle to hibernate (on battery) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\9D7815A6-7EE4-497E-8888-515A05F02364", + "DCSettingIndex", 0, )?; - // Never idle to hibernate (plugged in). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\9D7815A6-7EE4-497E-8888-515A05F02364"), - w!("ACSettingIndex"), + // Never idle to hibernate (plugged in) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\9D7815A6-7EE4-497E-8888-515A05F02364", + "ACSettingIndex", 0, )?; - // Never unattended idle to sleep (on battery). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0"), - w!("DCSettingIndex"), + // Never unattended idle to sleep (on battery) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0", + "DCSettingIndex", 0, )?; - // Never unattended idle to sleep (plugged in). - set_dword_gpo( - hklm, - w!(r"Software\Policies\Microsoft\Power\PowerSettings\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0"), - w!("ACSettingIndex"), + // Never unattended idle to sleep (plugged in) + set_dword( + &hklm, + r"Software\Policies\Microsoft\Power\PowerSettings\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0", + "ACSettingIndex", 0, )?; - // Disable the Hibernate entry in the Power Menu. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings"), - w!("ShowHibernateOption"), + // Disable the Hibernate entry in the Power Menu + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings", + "ShowHibernateOption", 0, )?; - // Disable the Sleep entry in the Power Menu. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings"), - w!("ShowSleepOption"), + // Disable the Sleep entry in the Power Menu + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings", + "ShowSleepOption", 0, )?; - - save_registry_gpo(hklm, gpo_hklm)?; - Ok(()) } diff --git a/src/gui/reduce_forensics.rs b/src/gui/reduce_forensics.rs index 01ffcb2..38996ce 100644 --- a/src/gui/reduce_forensics.rs +++ b/src/gui/reduce_forensics.rs @@ -1,7 +1,6 @@ use std::error::Error; use std::process::Command; -use windows::{core::w, Win32::System::{GroupPolicy::IGroupPolicyObject, Registry::{HKEY, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE}}}; - +use winsafe::{HKEY, prelude::advapi_Hkey}; use crate::common::*; /* Ignored for security reasons: @@ -10,44 +9,44 @@ use crate::common::*; */ pub fn run() -> Result<(), Box> { - let (hklm, gpo_hklm): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_LOCAL_MACHINE)?; - let (hkcu, gpo_hkcu): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_CURRENT_USER)?; + let hklm = HKEY::LOCAL_MACHINE; + let hkcu = HKEY::CURRENT_USER; // Do not analyze apps' execution time data. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib"), - w!("Disable Performance Counters"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib", + "Disable Performance Counters", 1, )?; // Do not keep track of recently opened files. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer"), - w!("NoRecentDocsHistory"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", + "NoRecentDocsHistory", 1, )?; // Disable Superfetch. - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Services\SysMain"), - w!("Start"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Services\SysMain", + "Start", 4, )?; - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Control\Session Manager\Management"), - w!("EnableSuperfetch"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Control\Session Manager\Management", + "EnableSuperfetch", 0, )?; // Disable Prefetch. - set_dword_gpo( - hklm, - w!(r"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters"), - w!("EnablePrefetcher"), + set_dword( + &hklm, + r"SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters", + "EnablePrefetcher", 0, )?; @@ -59,204 +58,201 @@ pub fn run() -> Result<(), Box> { .expect("fsutil.exe failed to execute"); // Disable "Application Impact Telemetry". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("AITEnable"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "AITEnable", 0, )?; // Disable "Program Compatibility Assistant". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisablePCA"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisablePCA", 1, )?; // Disable "Application Compatibility Engine". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisableEngine"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisableEngine", 1, )?; // Disable "SwitchBack Compatibility Engine". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("SbEnable"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "SbEnable", 0, )?; // Disable "User Steps Recorder". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisableUAR"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisableUAR", 1, )?; // Disable "Inventory Collector". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisableInventory"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisableInventory", 1, )?; // API Sampling monitors the sampled collection of application programming interfaces used during system runtime to help diagnose compatibility problems. - set_dword_gpo( - hkcu, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisableAPISamping"), + set_dword( + &hkcu, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisableAPISamping", 1, )?; // Application Footprint monitors the sampled collection of registry and file usage to help diagnose compatibility problems. - set_dword_gpo( - hkcu, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisableApplicationFootprint"), + set_dword( + &hkcu, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisableApplicationFootprint", 1, )?; // Install Tracing is a mechanism that tracks application installs to help diagnose compatibility problems. - set_dword_gpo( - hkcu, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisableInstallTracing"), + set_dword( + &hkcu, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisableInstallTracing", 1, )?; //The compatibility scan for backed up applications evaluates for compatibility problems in installed applications. - set_dword_gpo( - hkcu, - w!(r"SOFTWARE\Policies\Microsoft\Windows\AppCompat"), - w!("DisableWin32AppBackup"), + set_dword( + &hkcu, + r"SOFTWARE\Policies\Microsoft\Windows\AppCompat", + "DisableWin32AppBackup", 1, )?; // Disable "Program Compatibility Assistant" service. - set_dword_gpo(hklm, w!(r"SYSTEM\CurrentControlSet\Services"), w!("PcaSvc"), 4)?; + set_dword(&hklm, r"SYSTEM\CurrentControlSet\Services", "PcaSvc", 4)?; // Disable PerfTrack. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\WDI\{9c5a40da-b965-4fc3-8781-88dd50a6299d}"), - w!("ScenarioExecutionEnabled"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\WDI\{9c5a40da-b965-4fc3-8781-88dd50a6299d}", + "ScenarioExecutionEnabled", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Messenger\Client"), - w!("CEIP"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Messenger\Client", + "CEIP", 2, )?; // Disable tracking of application startups. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\EdgeUI"), - w!("DisableMFUTracking"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\EdgeUI", + "DisableMFUTracking", 1, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"), - w!("Start_TrackProgs"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", + "Start_TrackProgs", 0, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Policies\Microsoft\Windows\EdgeUI"), - w!("DisableMFUTracking"), + set_dword( + &hkcu, + r"Software\Policies\Microsoft\Windows\EdgeUI", + "DisableMFUTracking", 1, )?; // Fully disable the activity feed. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\System"), - w!("EnableActivityFeed"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\System", + "EnableActivityFeed", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\System"), - w!("PublishUserActivities"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\System", + "PublishUserActivities", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\System"), - w!("UploadUserActivities"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\System", + "UploadUserActivities", 0, )?; // Do not search disks to attempt fixing a missing shortcut. - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"), - w!("LinkResolveIgnoreLinkInfo"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", + "LinkResolveIgnoreLinkInfo", 1, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"), - w!("NoResolveSearch"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", + "NoResolveSearch", 1, )?; - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"), - w!("NoResolveTrack"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer", + "NoResolveTrack", 1, )?; // Disable Device Search History. - set_dword_gpo( - hkcu, - w!(r"Software\Microsoft\Windows\CurrentVersion\SearchSettings"), - w!("IsDeviceSearchHistoryEnabled"), + set_dword( + &hkcu, + r"Software\Microsoft\Windows\CurrentVersion\SearchSettings", + "IsDeviceSearchHistoryEnabled", 0, )?; // By default Windows does not automatically back-up the registry, but just in case they change this.. - set_dword_gpo( - hkcu, - w!(r"SYSTEM\CurrentControlSet\Control\Session Manager\Configuration Manager"), - w!("EnablePeriodicBackup"), + set_dword( + &hkcu, + r"SYSTEM\CurrentControlSet\Control\Session Manager\Configuration Manager", + "EnablePeriodicBackup", 0, )?; // Remove Recommended section from Start Menu. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Explorer"), - w!("HideRecommendedSection"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Explorer", + "HideRecommendedSection", 1, )?; // Remove frequent programs list from the Start Menu. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer"), - w!("NoStartMenuMFUprogramsList"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer", + "NoStartMenuMFUprogramsList", 1, )?; // Disable File History. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\FileHistory"), - w!("Disabled"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\FileHistory", + "Disabled", 1, )?; - save_registry_gpo(hklm, gpo_hklm)?; - save_registry_gpo(hkcu, gpo_hkcu)?; - Ok(()) } diff --git a/src/gui/reduce_online_data_collection.rs b/src/gui/reduce_online_data_collection.rs index e479aff..b727379 100644 --- a/src/gui/reduce_online_data_collection.rs +++ b/src/gui/reduce_online_data_collection.rs @@ -1,7 +1,6 @@ -use windows::{core::w, Win32::System::{GroupPolicy::IGroupPolicyObject, Registry::{HKEY, HKEY_LOCAL_MACHINE}}}; - use crate::common::*; use std::error::Error; +use winsafe::{HKEY, prelude::advapi_Hkey}; /* Ignored for security or usability reasons: - Find My Device @@ -10,171 +9,169 @@ use std::error::Error; */ pub fn run() -> Result<(), Box> { - let (hklm, gpo_hklm): (HKEY, IGroupPolicyObject) = init_registry_gpo(HKEY_LOCAL_MACHINE)?; + let hklm = HKEY::LOCAL_MACHINE; // Don't allow online tips. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\AllowOnlineTips"), - w!("AllowOnlineTips"), + set_dword( + &hklm, + r"SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\AllowOnlineTips", + "AllowOnlineTips", 1, )?; // Don't allow users to enable online speech recongition services. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\InputPersonalization"), - w!("AllowInputPersonalization"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\InputPersonalization", + "AllowInputPersonalization", 0, )?; // Remove Personalized Website Recommendations from the Recommended section in the Start Menu. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Explorer"), - w!("HideRecommendedPersonalizedSites"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Explorer", + "HideRecommendedPersonalizedSites", 1, )?; // Turn off account-based insights, recent, favorite, and recommended files in File Explorer. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Explorer"), - w!("HideRecommendedSection"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Explorer", + "HideRecommendedSection", 1, )?; // Prevent device metadata retrieval from the Internet. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Device Metadata"), - w!("PreventDeviceMetadataFromNetwork"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Device Metadata", + "PreventDeviceMetadataFromNetwork", 1, )?; // Turn off Search Companion content file updates. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\SearchCompanion"), - w!("DisableContentFileUpdates"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\SearchCompanion", + "DisableContentFileUpdates", 1, )?; // Don't allow Clipboard synchronization across devices. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\System"), - w!("AllowCrossDeviceClipboard"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\System", + "AllowCrossDeviceClipboard", 0, )?; // Don't allow downloading updates to the Disk Failure Prediction Model. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\StorageHealth"), - w!("AllowDiskHealthModelUpdates"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\StorageHealth", + "AllowDiskHealthModelUpdates", 0, )?; // Don't allow sideloaded apps to auto-update in the background. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Appx"), - w!("DisableBackgroundAutoUpdates"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Appx", + "DisableBackgroundAutoUpdates", 0, )?; // "Cloud optimized content / Windows experiences" are used for advertising, but aren't disabled in defaults.rs to keep the OS "stock". - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\CloudContent"), - w!("DisableCloudOptimizedContent"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\CloudContent", + "DisableCloudOptimizedContent", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\CloudContent"), - w!("DisableConsumerAccountStateContent"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\CloudContent", + "DisableConsumerAccountStateContent", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\CloudContent"), - w!("DisableSoftLanding"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\CloudContent", + "DisableSoftLanding", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\CloudContent"), - w!("DisableSoftLanding"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\CloudContent", + "DisableSoftLanding", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\CloudContent"), - w!("DisableWindowsConsumerFeatures"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\CloudContent", + "DisableWindowsConsumerFeatures", 1, )?; - // Don't allow Windows to sync cellular messages to Microsoft's cloud services. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Messaging"), - w!("AllowMessageSync"), + // Don't allow Windows to sync cellular messages to Mircosoft's cloud services. + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Messaging", + "AllowMessageSync", 0, )?; // Disable an old virtual assistant that excessively used the internet and violated privacy. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Windows Search"), - w!("AllowCortana"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Windows Search", + "AllowCortana", 0, )?; // Disable Windows Search from using the "cloud" / internet. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Windows Search"), - w!("AllowCloudSearch"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Windows Search", + "AllowCloudSearch", 0, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Windows Search"), - w!("DisableWebSearch"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Windows Search", + "DisableWebSearch", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Windows Search"), - w!("EnableDynamicContentInWSB"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Windows Search", + "EnableDynamicContentInWSB", 1, )?; - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Windows\Windows Search"), - w!("ConnectedSearchUseWeb"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Windows\Windows Search", + "ConnectedSearchUseWeb", 0, )?; // Don't automatically download a new speech model. - set_dword_gpo( - hklm, - w!(r"Machine\SOFTWARE\Policies\Microsoft\Speech"), - w!("AllowSpeechModelUpdate"), + set_dword( + &hklm, + r"Machine\SOFTWARE\Policies\Microsoft\Speech", + "AllowSpeechModelUpdate", 0, )?; // Don't show News and Interests or other widgets. - set_dword_gpo( - hklm, - w!(r"SOFTWARE\Policies\Microsoft\Dsh"), - w!("AllowNewsAndInterests"), + set_dword( + &hklm, + r"SOFTWARE\Policies\Microsoft\Dsh", + "AllowNewsAndInterests", 0, )?; - - save_registry_gpo(hklm, gpo_hklm)?; Ok(()) }