Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the option to Block Razer automatic installs #2715

Merged
merged 8 commits into from
Sep 20, 2024

Conversation

xicor22
Copy link
Contributor

@xicor22 xicor22 commented Sep 11, 2024

Type of Change

  • New feature

Description

Added the option to block automatic installation of razer software using the code from the chris titus original Block-Razer repo.

Testing

Tested for the following cases:

  • Win 11 Fresh
  • Win 11 with script used from this repo

Issue related to PR

Additional Information

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no errors/warnings/merge conflicts.

commit c674d5e
Author: Saksham Singh <sakshamsingh.93502@gmail.com>
Date:   Wed Sep 11 19:34:44 2024 +0530

    desc update

commit 3d8bf2b
Author: Saksham Singh <sakshamsingh.93502@gmail.com>
Date:   Wed Sep 11 19:30:23 2024 +0530

    Added Razer Block

    Added the razer block by chris titus under the Fixes Section
@Real-MullaC
Copy link
Contributor

Hello @xicor22,

Thank you for your PR but this would be a tweak and not a feature. Please could this be moved to tweaks.json under the Advanced Tweaks Section.

@xicor22
Copy link
Contributor Author

xicor22 commented Sep 11, 2024


  "WPFRazerBlock": {
    "Content": "Block Razer software autoinstall",
    "Description": "It disables the automatic driver installation and denies write permission of Razer folder to system which prevents the automatic install.",
    "category": "z__Advanced Tweaks - CAUTION",
    "panel": "1",
    "Order": "a031_",
    "registry": [
      {
        "Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DriverSearching",
        "Name": "SearchOrderConfig",
        "Type": "DWord",
        "Value": "0",
        "OriginalValue": "1"
      },
      {
        "Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Device Installer",
        "Name": "DisableCoInstallers",
        "Type": "DWord",
        "Value": "1",
        "OriginalValue": "0"
      }
    ],
    "InvokeScript": [
      "Remove-Item \"C:\\Windows\\Installer\\Razer\" -Recurse -Force
      New-Item -Path \"C:\\Windows\\Installer\" -Name \"Razer\" -ItemType \"directory\"
      $Acl = Get-Acl \"C:\\Windows\\Installer\\Razer\"
      $Ar = New-Object System.Security.AccessControl.FileSystemAccessRule(\"NT AUTHORITY\\SYSTEM\",\"Write\",\"ContainerInherit,ObjectInherit\",\"None\",\"Deny\")
      $Acl.SetAccessRule($Ar)
      Set-Acl \"C:\\Windows\\Installer\\Razer\" $Acl"
    ],
    "UndoScript": [
      "Remove-Item \"C:\\Windows\\Installer\\Razer\" -Recurse -Force
      New-Item -Path \"C:\\Windows\\Installer\" -Name \"Razer\" -ItemType \"directory\""
    ],
    "link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/RazerBlock"

I added this in the tweaks.json and got this error
image

I have the same format as other tweaks or have I missed something?

@Real-MullaC
Copy link
Contributor

"WPFRazerBlock": {
    "Content": "Block Razer software autoinstall",
    "Description": "It disables the automatic driver installation and denies write permission of Razer folder to system which prevents the automatic install.",
    "category": "Essential Tweaks",
    "panel": "1",
    "Order": "a017_",
    "registry": [
      {
        "Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DriverSearching",
        "Name": "SearchOrderConfig",
        "Type": "DWord",
        "Value": "0",
        "OriginalValue": "1"
      },
      {
        "Path": "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Device Installer",
        "Name": "DisableCoInstallers",
        "Type": "DWord",
        "Value": "1",
        "OriginalValue": "0"
      }
    ],
    "InvokeScript": [
      "Remove-Item \"C:\\Windows\\Installer\\Razer\" -Recurse -Force",
      "New-Item -Path \"C:\\Windows\\Installer\" -Name \"Razer\" -ItemType \"directory\"",
      "$Acl = Get-Acl \"C:\\Windows\\Installer\\Razer\"",
      "$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule(\"NT AUTHORITY\\SYSTEM\",\"Write\",\"ContainerInherit,ObjectInherit\",\"None\",\"Deny\")",
      "$Acl.SetAccessRule($Ar)",
      "Set-Acl \"C:\\Windows\\Installer\\Razer\" $Acl"
    ],
    "UndoScript": [
      "Remove-Item \"C:\\Windows\\Installer\\Razer\" -Recurse -Force",
      "New-Item -Path \"C:\\Windows\\Installer\" -Name \"Razer\" -ItemType \"directory\""
    ],
    "link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/RazerBlock"
  }

I added this in the tweaks.json and got this error image

I have the same format as other tweaks or have I missed something?

This could be due to issues with tweaks currently.

@xicor22
Copy link
Contributor Author

xicor22 commented Sep 11, 2024

even though i select another tweak to get around that bug, my razer block tweak is still not getting applied

@xicor22
Copy link
Contributor Author

xicor22 commented Sep 11, 2024

"WPFTweaksRazerBlock": {
    "Content": "Block Razer software autoinstall",
    "Description": "It disables the automatic driver installation and denies write permission of Razer folder to system which prevents the automatic install.",
    "category": "z__Advanced Tweaks - CAUTION",
    "panel": "1",
    "Order": "a031_",
    "InvokeScript": [
      "
        function RazerBlock {
          $RazerPath = \"C:\\Windows\\Installer\\Razer\"
          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-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
          }
        RazerBlock
      "
    ],
    "UndoScript": [
      "
        function RazerUnblock {
          $RazerPath = \"C:\\Windows\\Installer\\Razer\"
          Set-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DriverSearching\" -Name \"SearchOrderConfig\" -Type DWord -Value 1
          Set-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Device Installer\" -Name \"DisableCoInstallers\" -Type DWord -Value 0
          Remove-Item $RazerPath -Recurse -Force
          New-Item -Path \"C:\\Windows\\Installer\\\" -Name \"Razer\" -ItemType \"directory\"
          }
        RazerUnblock
      "
    ],
    "link": "https://christitustech.github.io/winutil/dev/tweaks/Essential-Tweaks/RazerBlock"

I looked at this for quite a while and cant seem to find any issues but the code in invoke script is not running. Am I missing something here?

The previous "select a tweaks" error was caused because I didn't put "Tweak" in "WPFRazerBlock".

@ChrisTitusTech ChrisTitusTech added the enhancement New feature or request label Sep 12, 2024
@MyDrift-user
Copy link
Contributor

MyDrift-user commented Sep 12, 2024

Hey @xicor22, thanks for the PR, you moved the reg changes into the invoke- & undo script again, could you please add them sepeately like you did before?

Also the function wrapping and calling kind of seems unneccessary due to it only beeing called there.
PS: The Tweaks generally did not work temporarily, but should work now again.

Otherwise I think it looks good :)

@xicor22
Copy link
Contributor Author

xicor22 commented Sep 12, 2024

I just made the requested changes and tested them. Everything's working fine.

Copy link
Contributor

@MyDrift-user MyDrift-user left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, looks fine to me now 👍

@MyDrift-user
Copy link
Contributor

You forgot to remove the comma in feature.json

xicor22 added a commit to xicor22/winutil that referenced this pull request Sep 15, 2024
@xicor22 xicor22 mentioned this pull request Sep 15, 2024
6 tasks
@ChrisTitusTech ChrisTitusTech merged commit 06baebc into ChrisTitusTech:main Sep 20, 2024
1 check passed
ChrisTitusTech pushed a commit that referenced this pull request Oct 1, 2024
* Squashed commit of the following:

commit c674d5e
Author: Saksham Singh <sakshamsingh.93502@gmail.com>
Date:   Wed Sep 11 19:34:44 2024 +0530

    desc update

commit 3d8bf2b
Author: Saksham Singh <sakshamsingh.93502@gmail.com>
Date:   Wed Sep 11 19:30:23 2024 +0530

    Added Razer Block

    Added the razer block by chris titus under the Fixes Section

* Moved razer-block from features to tweaks

* Updated tweaks.json

* Added option to enable ssh server under config tab

* Revert "Added option to enable ssh server under config tab"

This reverts commit ade4142.

* Added Option to enable ssh server under config tab

* updated docs

* Removed #2715 from this PR

* update variable name

* Fixed authorized_keys file creation issue

auth key file was not being created due to incomplete file path from the $env:HOMEPATH and also corrected the ssh directory to .ssh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Add Block Razor script
4 participants