Closed eneerge closed 3 weeks 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.
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.
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.
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
I commit to main a small check, you can test if it still happens?
Description
None of the group policy tweaks are applied. Video attached.
Steps to reproduce
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.
SO version
Windows 10
Confirmation