From 8383c8291e442990220e69a05c2fbad7c96f10ef Mon Sep 17 00:00:00 2001 From: Ian Div Date: Mon, 26 Jun 2023 14:49:55 +0800 Subject: [PATCH] code cleaup --- Win11Tweaker/Form1.cs | 266 +----------------------------------------- 1 file changed, 1 insertion(+), 265 deletions(-) diff --git a/Win11Tweaker/Form1.cs b/Win11Tweaker/Form1.cs index da8c36b..0eca08f 100644 --- a/Win11Tweaker/Form1.cs +++ b/Win11Tweaker/Form1.cs @@ -443,271 +443,7 @@ private void runReg(string key, bool isChecked) break; } - //using (PowerShell ps = PowerShell.Create()) - //{ - // switch (key) - // { - // case nameof(Settings.Default.contextMenuChecked): - // if (isChecked) - // { - // ps.AddScript(@" - //# Enable Classic Context Menu - //$regPath = ""HKCU:\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"" - - //# Check if the registry key exists - //if (-not (Test-Path $regPath)) { - // # Create the registry key if it doesn't exist - // New-Item -Path $regPath -Force | Out-Null - //} - - //# Set the default value - //Set-ItemProperty -Path $regPath -Name ""(Default)"" -Value """" - - //#RESTART EXPLORER!! - - // "); - - // } - // else - // { - // ps.AddScript(@" - //# Disable Classic Context Menu - //$regPath = ""REGISTRY::HKEY_CURRENT_USER\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}"" - //Remove-Item -Path $regPath -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable RemoveError - - //if ($RemoveError) { - // Write-Host ""Error removing registry path: $regPath"" - // Write-Host $RemoveError - //} - //else { - // Write-Host ""Registry path removed successfully: $regPath"" - //} - - - //# RESTART EXPLORER!! - - // "); - - // } - // onRestartExplorer(); - // break; - // case nameof(Settings.Default.webSearchChecked): - // if (isChecked) - // { - // ps.AddScript(@" - //# Disable Web Search - //Set-ItemProperty -Path ""HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer"" -Name ""DisableSearchBoxSuggestions"" -Value 1 - - //#SIGNOUT - - //"); - // } - // else - // { - // ps.AddScript(@" - //# Enable Web Search - //Remove-ItemProperty -Path ""HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer"" -Name ""DisableSearchBoxSuggestions"" -ErrorAction SilentlyContinue - //#SIGNOUT - - //"); - // } - // onSignOut(); - // break; - // case nameof(Settings.Default.lockScreennChecked): - // if (isChecked) - // { - // ps.AddScript(@" - //#Disable Lock Screen - //$RegistryPath = ""HKLM:\SOFTWARE\Policies\Microsoft\Windows"" - //$PersonalizationKey = ""Personalization"" - //$NoLockScreenValueName = ""NoLockScreen"" - //$NoLockScreenValueData = 1 - - //# Create or open the Personalization key - //New-Item -Path $RegistryPath -Name $PersonalizationKey -Force | Out-Null - - //# Set the NoLockScreen value under the Personalization key - //Set-ItemProperty -Path ""$RegistryPath\$PersonalizationKey"" -Name $NoLockScreenValueName -Value $NoLockScreenValueData -Type DWORD -Force - - //"); - // } - // else - // { - // ps.AddScript(@" - //#Enable Lock Screen - //$RegistryPath = ""HKLM:\SOFTWARE\Policies\Microsoft\Windows"" - //$PersonalizationKey = ""Personalization"" - //$NoLockScreenValueName = ""NoLockScreen"" - //$NoLockScreenValueData = 0 - - //# Create or open the Personalization key - //New-Item -Path $RegistryPath -Name $PersonalizationKey -Force | Out-Null - - //# Set the NoLockScreen value under the Personalization key - //Set-ItemProperty -Path ""$RegistryPath\$PersonalizationKey"" -Name $NoLockScreenValueName -Value $NoLockScreenValueData -Type DWORD -Force - - //"); - // } - // break; - // case nameof(Settings.Default.compactViewChecked): - // if (isChecked) - // { - // ps.AddScript(@" - //#Enable Compact View - //$RegistryPath = ""HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"" - //$UseCompactModeValueName = ""UseCompactMode"" - //$UseCompactModeValueData = 1 - - //# Check if the UseCompactMode value exists - //if (!(Test-Path ""$RegistryPath\$UseCompactModeValueName"")) { - // # Create the UseCompactMode value if it doesn't exist - // New-ItemProperty -Path $RegistryPath -Name $UseCompactModeValueName -PropertyType DWORD -Value $UseCompactModeValueData -Force | Out-Null - // Write-Host ""Value '$UseCompactModeValueName' created with value '$UseCompactModeValueData'."" - //} else { - // # Modify the existing UseCompactMode value - // Set-ItemProperty -Path $RegistryPath -Name $UseCompactModeValueName -Value $UseCompactModeValueData -Force - // Write-Host ""Value '$UseCompactModeValueName' modified to '$UseCompactModeValueData'."" - //} - // "); - // } - // else - // { - // ps.AddScript(@" - //#Disable Compact View - //$RegistryPath = ""HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"" - //$UseCompactModeValueName = ""UseCompactMode"" - //$UseCompactModeValueData = 0 - - //# Check if the UseCompactMode value exists - //if (!(Test-Path ""$RegistryPath\$UseCompactModeValueName"")) { - // # Create the UseCompactMode value if it doesn't exist - // New-ItemProperty -Path $RegistryPath -Name $UseCompactModeValueName -PropertyType DWORD -Value $UseCompactModeValueData -Force | Out-Null - // Write-Host ""Value '$UseCompactModeValueName' created with value '$UseCompactModeValueData'."" - //} else { - // # Modify the existing UseCompactMode value - // Set-ItemProperty -Path $RegistryPath -Name $UseCompactModeValueName -Value $UseCompactModeValueData -Force - // Write-Host ""Value '$UseCompactModeValueName' modified to '$UseCompactModeValueData'."" - //} - - // "); - // } - // break; - // case nameof(Settings.Default.previewPaneChecked): - // if (isChecked) - // { - // ps.AddScript(@" - //# Enable Preview Pane - //$registryPath = ""AllFilesystemObjects\shell\Windows.previewpane"" - //New-Item -Path $registryPath -Force | Out-Null - //Set-ItemProperty -Path $registryPath -Name ""CanonicalName"" -Value ""{1380d028-a77f-4c12-96c7-ea276333f982}"" - //Set-ItemProperty -Path $registryPath -Name ""Description"" -Value ""@shell32.dll,-31416"" - //Set-ItemProperty -Path $registryPath -Name ""Icon"" -Value ""shell32.dll,-16814"" - //Set-ItemProperty -Path $registryPath -Name ""MUIVerb"" -Value ""@shell32.dll,-31415"" - //Set-ItemProperty -Path $registryPath -Name ""PaneID"" -Value ""{43abf98b-89b8-472d-b9ce-e69b8229f019}"" - //Set-ItemProperty -Path $registryPath -Name ""PaneVisibleProperty"" -Value ""PreviewPaneSizer_Visible"" - //Set-ItemProperty -Path $registryPath -Name ""PolicyID"" -Value ""{17067f8d-981b-42c5-98f8-5bc016d4b073}"" - - //$registryPath = ""Directory\Background\shell\Windows.previewpane"" - //New-Item -Path $registryPath -Force | Out-Null - //Set-ItemProperty -Path $registryPath -Name ""CanonicalName"" -Value ""{1380d028-a77f-4c12-96c7-ea276333f982}"" - //Set-ItemProperty -Path $registryPath -Name ""Description"" -Value ""@shell32.dll,-31416"" - //Set-ItemProperty -Path $registryPath -Name ""Icon"" -Value ""shell32.dll,-16814"" - //Set-ItemProperty -Path $registryPath -Name ""MUIVerb"" -Value ""@shell32.dll,-31415"" - //Set-ItemProperty -Path $registryPath -Name ""PaneID"" -Value ""{43abf98b-89b8-472d-b9ce-e69b8229f019}"" - //Set-ItemProperty -Path $registryPath -Name ""PaneVisibleProperty"" -Value ""PreviewPaneSizer_Visible"" - //Set-ItemProperty -Path $registryPath -Name ""PolicyID"" -Value ""{17067f8d-981b-42c5-98f8-5bc016d4b073}"" - - //$registryPath = ""Drive\shell\Windows.previewpane"" - //New-Item -Path $registryPath -Force | Out-Null - //Set-ItemProperty -Path $registryPath -Name ""CanonicalName"" -Value ""{1380d028-a77f-4c12-96c7-ea276333f982}"" - //Set-ItemProperty -Path $registryPath -Name ""Description"" -Value ""@shell32.dll,-31416"" - //Set-ItemProperty -Path $registryPath -Name ""Icon"" -Value ""shell32.dll,-16814"" - //Set-ItemProperty -Path $registryPath -Name ""MUIVerb"" -Value ""@shell32.dll,-31415"" - //Set-ItemProperty -Path $registryPath -Name ""PaneID"" -Value ""{43abf98b-89b8-472d-b9ce-e69b8229f019}"" - //Set-ItemProperty -Path $registryPath -Name ""PaneVisibleProperty"" -Value ""PreviewPaneSizer_Visible"" - //Set-ItemProperty -Path $registryPath -Name ""PolicyID"" -Value ""{17067f8d-981b-42c5-98f8-5bc016d4b073}"" - - //$registryPath = ""LibraryFolder\background\shell\Windows.previewpane"" - //New-Item -Path $registryPath -Force | Out-Null - //Set-ItemProperty -Path $registryPath -Name ""CanonicalName"" -Value ""{1380d028-a77f-4c12-96c7-ea276333f982}"" - //Set-ItemProperty -Path $registryPath -Name ""Description"" -Value ""@shell32.dll,-31416"" - //Set-ItemProperty -Path $registryPath -Name ""Icon"" -Value ""shell32.dll,-16814"" - //Set-ItemProperty -Path $registryPath -Name ""MUIVerb"" -Value ""@shell32.dll,-31415"" - //Set-ItemProperty -Path $registryPath -Name ""PaneID"" -Value ""{43abf98b-89b8-472d-b9ce-e69b8229f019}"" - //Set-ItemProperty -Path $registryPath -Name ""PaneVisibleProperty"" -Value ""PreviewPaneSizer_Visible"" - //Set-ItemProperty -Path $registryPath -Name ""PolicyID"" -Value ""{17067f8d-981b-42c5-98f8-5bc016d4b073}"" - - // "); - // } - // else - // { - // ps.AddScript(@" - //# Disable Preview Pane - //Remove-Item -Path ""AllFilesystemObjects\shell\Windows.previewpane"" -Force -Confirm:$false - //Remove-Item -Path ""Directory\Background\shell\Windows.previewpane"" -Force -Confirm:$false - //Remove-Item -Path ""Drive\shell\Windows.previewpane"" -Force -Confirm:$false - //Remove-Item -Path ""LibraryFolder\background\shell\Windows.previewpane"" -Force -Confirm:$false - - // "); - // } - // break; - // case nameof(Settings.Default.printScrChecked): - // if (isChecked) - // { - // ps.AddScript(@" - //# Create SnapShot registry key and set its (Default) value - //$registryPath = ""HKCU:\AppEvents\Schemes\Apps\.Default\SnapShot"" - //if (-not (Test-Path $registryPath)) { - // New-Item -Path $registryPath -Force | Out-Null - //} - //Set-ItemProperty -Path $registryPath -Name ""(Default)"" -Value """" - - //# Create .Current folder and set its (Default) key value - //$currentFolderPath = ""HKCU:\AppEvents\Schemes\Apps\.Default\SnapShot\.Current"" - //if (-not (Test-Path $currentFolderPath)) { - // New-Item -Path $currentFolderPath -Force | Out-Null - //} - //Set-ItemProperty -Path $currentFolderPath -Name ""(Default)"" -Value ""C:\Windows\media\Windows Notify System Generic.wav"" - - //# Create .Default folder and set its (Default) key value - //$defaultFolderPath = ""HKCU:\AppEvents\Schemes\Apps\.Default\SnapShot\.Default"" - //if (-not (Test-Path $defaultFolderPath)) { - // New-Item -Path $defaultFolderPath -Force | Out-Null - //} - //Set-ItemProperty -Path $defaultFolderPath -Name ""(Default)"" -Value ""C:\Windows\media\Windows Notify System Generic.wav"" - - //"); - // } - // else - // { - // ps.AddScript(@" - //# Delete SnapShot folder without prompt - //$registryPath = ""HKCU:\AppEvents\Schemes\Apps\.Default\SnapShot"" - //if (Test-Path $registryPath) { - // Remove-Item -Path $registryPath -Recurse -Force -Confirm:$false - //} - - //"); - // } - // break; - // } - - - // var output = ps.Invoke(); - // if (ps.HadErrors) - // { - // Console.WriteLine("Script execution encountered errors:"); - // foreach (var error in ps.Streams.Error) - // { - // Console.WriteLine(error.ToString()); - // } - // } - // else - // { - // Console.WriteLine("Script executed successfully."); - // // Handle successful execution here - // } - //} + } }