Last active
August 17, 2024 00:59
-
-
Save LiEnby/b95ffb5e2830aada2fa33d6cba6bd70a to your computer and use it in GitHub Desktop.
Disable Parental Controls on Windows 10/11 Batch Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
set "params=%*" | |
cd /d "%~dp0" && ( if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs" ) && fsutil dirty query %systemdrive% 1>nul 2>nul || ( echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "cmd.exe", "/k cd ""%~sdp0"" && %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" && "%temp%\getadmin.vbs" && exit /B ) | |
echo This script completley removes Parental Controls from Windows 10 / 11 | |
echo Press any key to disable parental controls | |
pause>nul | |
echo Blocking parental controls server ... | |
echo # Disable parental controls >> %WINDIR%\System32\drivers\etc\hosts | |
echo 0.0.0.0 rs3clients.timeusage.family.microsoft.com >> %WINDIR%\System32\drivers\etc\hosts | |
echo 0.0.0.0 clientfd.family.microsoft.com >> %WINDIR%\System32\drivers\etc\hosts | |
echo 0.0.0.0 family.microsoft.com >> %WINDIR%\System32\drivers\etc\hosts | |
echo Disabling parental controls service.. | |
sc stop WpcMonSvc | |
sc config WpcMonSvc start= disabled | |
echo Deleting parental controls service... | |
reg delete "HKLM\SYSTEM\CurrentControlSet\Services\WpcMonSvc" /f | |
echo Deleting WpcDesktopMonSvc.dll ... | |
takeown /f %WINDIR%\System32\WpcDesktopMonSvc.dll | |
cacls %WINDIR%\System32\WpcDesktopMonSvc.dll /e /p %USERNAME%:F | |
del %WINDIR%\System32\WpcDesktopMonSvc.dll /Q /F | |
echo Deleting cached Parental Control Settings in ProgramData ... | |
takeown /f "%PROGRAMDATA%\Microsoft\Windows\Parental Controls" | |
cacls "%PROGRAMDATA%\Microsoft\Windows\Parental Controls" /e /p %USERNAME%:F | |
del "%PROGRAMDATA%\Microsoft\Windows\Parental Controls" /S /Q /F | |
rd "%PROGRAMDATA%\Microsoft\Windows\Parental Controls" /S /Q | |
echo Deleting cached Parental Control Settings in Registry ... | |
powershell -noprofile -noninteractive -command "function Take-Permissions { param($rootKey, $key, [System.Security.Principal.SecurityIdentifier]$sid = 'S-1-5-32-545', $recurse = $true); switch -regex ($rootKey) { 'HKCU|HKEY_CURRENT_USER' { $rootKey = 'CurrentUser' } 'HKLM|HKEY_LOCAL_MACHINE' { $rootKey = 'LocalMachine' } 'HKCR|HKEY_CLASSES_ROOT' { $rootKey = 'ClassesRoot' } 'HKCC|HKEY_CURRENT_CONFIG' { $rootKey = 'CurrentConfig' } 'HKU|HKEY_USERS' { $rootKey = 'Users' } }; $import = '[DllImport(\"ntdll.dll\")] public static extern int RtlAdjustPrivilege(ulong a, bool b, bool c, ref bool d);'; $ntdll = Add-Type -Member $import -Name NtDll -PassThru; $privileges = @{ SeTakeOwnership = 9; SeBackup = 17; SeRestore = 18 }; foreach ($i in $privileges.Values) { $null = $ntdll::RtlAdjustPrivilege($i, 1, 0, [ref]0) }; function Take-KeyPermissions { param($rootKey, $key, $sid, $recurse, $recurseLevel = 0); $regKey = [Microsoft.Win32.Registry]::$rootKey.OpenSubKey($key, 'ReadWriteSubTree', 'TakeOwnership'); $acl = New-Object System.Security.AccessControl.RegistrySecurity; $acl.SetOwner($sid); $regKey.SetAccessControl($acl); $acl.SetAccessRuleProtection($false, $false); $regKey.SetAccessControl($acl); if ($recurseLevel -eq 0) { $regKey = $regKey.OpenSubKey('', 'ReadWriteSubTree', 'ChangePermissions'); $rule = New-Object System.Security.AccessControl.RegistryAccessRule($sid, 'FullControl', 'ContainerInherit', 'None', 'Allow'); $acl.ResetAccessRule($rule); $regKey.SetAccessControl($acl); }; if ($recurse) { foreach($subKey in $regKey.OpenSubKey('').GetSubKeyNames()) { Take-KeyPermissions $rootKey ($key+'\'+$subKey) $sid $recurse ($recurseLevel+1); } }; }; Take-KeyPermissions $rootKey $key $sid $recurse; };Take-Permissions 'HKLM' 'SOFTWARE\Microsoft\Windows\CurrentVersion\Parental Controls' 'S-1-5-32-544' $true;" | |
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Parental Controls" /f | |
echo Done! .. | |
pause>nul |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this doesn't work on my laptop