SegoCode / DebloBat

⚙️ Yet another (and ugly) debloat, optimizer and tweaker for Windows 11 based on group policies
Other
42 stars 3 forks source link

[BUG REPORT] - Policies dont apply #10

Closed eneerge closed 3 weeks ago

eneerge commented 1 month ago

Description

None of the group policy tweaks are applied. Video attached.

Steps to reproduce

  1. Launch with admin Permissions
  2. Select [1]
  3. Select any option

Expected behavior

Registry values for the policies should be applied

Actual behavior

No policies are applied and the script falsely changes all options to "Disabled" despite selecting any option. debl

SO version

Windows 10

Confirmation

eneerge commented 1 month ago

It seems when it gets to: reg query %path% /v %key% > nul 2>&1

This is the error: 'reg' is not recognized as an internal or external command,

reg seems to work from a regular command line, but not in the script.

eneerge commented 1 month ago

At the beginning of the script when it does: reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\Windows" /v CEIPEnable

This is the (correct) error it returns: ERROR: The system was unable to find the specified registry key or value.

So reg query works there, but not later in the script for some reason.

eneerge commented 1 month ago

When calling "set path=" this is causing it to set the PATH environment variable. This is forcing reg.exe out of the environment. If you rename "PATH" to "policyPath", that fixes the issue.

See here:

echo checking reg query command 1...
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\Windows" /v CEIPEnable
pause

if %N%==1 (set PATH="HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\Windows" && set key=CEIPEnable && set value=0)

echo checking reg query command 2...
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\Windows" /v CEIPEnable
pause

Update it to:

echo checking reg query command 1...
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\Windows" /v CEIPEnable
pause

if %N%==1 (set policypath="HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\Windows" && set key=CEIPEnable && set value=0)

echo checking reg query command 2...
reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\SQMClient\Windows" /v CEIPEnable
pause

This makes it work. Simply rename the PATH variable and all is good.

SegoCode commented 1 month ago

Yes, that's because you executed deblo.bat with administrator rights, and you lost the scope of the environment, if the entry point of deblo.bat is not executed as administrator it should work fine. I made deblo.bat not as administrator so that every time I launched a terminal the window, variables and environment would be reset. I must control that case, or otherwise apply what you say, since "path" as variables is a bit sensitive

SegoCode commented 1 month ago

I commit to main a small check, you can test if it still happens?