diff --git a/config/feature.json b/config/feature.json index 10835451..c8dd9d73 100644 --- a/config/feature.json +++ b/config/feature.json @@ -242,6 +242,15 @@ "ButtonWidth": "300", "link": "https://christitustech.github.io/winutil/dev/features/Fixes/RunAdobeCCCleanerTool" }, + "WPFRazerBlock": { + "Content": "Block Razer", + "category": "Fixes", + "panel": "1", + "Order": "a046_", + "Type": "Button", + "ButtonWidth": "300", + "link": "https://christitustech.github.io/winutil/dev/features/Fixes/razer" + }, "WPFPanelnetwork": { "Content": "Network Connections", "category": "Legacy Windows Panels", diff --git a/functions/public/Invoke-WPFButton.ps1 b/functions/public/Invoke-WPFButton.ps1 index 9f768fd8..4e672b1b 100644 --- a/functions/public/Invoke-WPFButton.ps1 +++ b/functions/public/Invoke-WPFButton.ps1 @@ -48,6 +48,7 @@ function Invoke-WPFButton { "WPFFixesUpdate" {Invoke-WPFFixesUpdate} "WPFFixesWinget" {Invoke-WPFFixesWinget} "WPFRunAdobeCCCleanerTool" {Invoke-WPFRunAdobeCCCleanerTool} + "WPFRazerBlock" {Invoke-WPFRazerBlock} "WPFFixesNetwork" {Invoke-WPFFixesNetwork} "WPFUpdatesdisable" {Invoke-WPFUpdatesdisable} "WPFUpdatessecurity" {Invoke-WPFUpdatessecurity} diff --git a/functions/public/Invoke-WPFRazerBlock.ps1 b/functions/public/Invoke-WPFRazerBlock.ps1 new file mode 100644 index 00000000..bea00fee --- /dev/null +++ b/functions/public/Invoke-WPFRazerBlock.ps1 @@ -0,0 +1,22 @@ +function Invoke-WPFRazerBlock { + <# + .SYNOPSIS + Blocks razer software automatic install. + .DESCRIPTION + It disables the automatic driver installation and denies write permission of razer folder to system which prevents the automatic install. + #> + $RazerPath = "C:\Windows\Installer\Razer" + + # Disable driver auto-install via registry + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching" -Name "SearchOrderConfig" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Device Installer" -Name "DisableCoInstallers" -Type DWord -Value 1 + + # Remove and lock install directory + Remove-Item $RazerPath -Recurse -Force + New-Item -Path "C:\Windows\Installer\" -Name "Razer" -ItemType "directory" + $Acl = Get-Acl $RazerPath + $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("NT AUTHORITY\SYSTEM", "Write", "ContainerInherit,ObjectInherit", "None", "Deny") + + $Acl.SetAccessRule($Ar) + Set-Acl $RazerPath $Acl +}