Batch File to Disable Windows Services

Save the Code with .bat extension and run as admin:

@echo off
setlocal

:MENU
cls
echo ================================
echo Manage Windows Services
echo ================================
echo 1. Disable Services
echo 2. Enable Services
echo 3. Exit
echo ================================
set /p choice="Enter your choice (1-3): "

if "%choice%"=="1" goto DISABLE
if "%choice%"=="2" goto ENABLE
if "%choice%"=="3" exit
echo Invalid choice. Please try again.
timeout /t 2
goto MENU

:DISABLE
echo Disabling Services...
call :DisableService "ActiveX Installer"
call :DisableService "Assigned Access Manager Service"
call :DisableService "BitLocker Drive Encryption Service"
call :DisableService "Certificate Propagation"
call :DisableService "Connected User Experience and Telemetry"
call :DisableService "Diagnostic Execution Service"
call :DisableService "Diagnostic Policy Service"
call :DisableService "Diagnostic Service Host"
call :DisableService "Diagnostic System Host"
call :DisableService "Geolocation Service"
call :DisableService "IpHelper"
call :DisableService "Netlogon"
call :DisableService "Optimize Drives"
call :DisableService "Parental Controls"
call :DisableService "Phone Service"
call :DisableService "Remote Desktop Configuration"
call :DisableService "Remote Desktop Services Port Redirector"
call :DisableService "Sensor Service"
call :DisableService "Smart Card"
call :DisableService "Smart Card Device Enumerator"
call :DisableService "Smart Card Removal Policy"
call :DisableService "SysMain"
call :DisableService "Windows Biometric Service"
call :DisableService "Work Folders"

echo All specified services have been disabled.
pause
goto MENU

:ENABLE
echo Enabling Services...
call :EnableService "ActiveX Installer"
call :EnableService "Assigned Access Manager Service"
call :EnableService "BitLocker Drive Encryption Service"
call :EnableService "Certificate Propagation"
call :EnableService "Connected User Experience and Telemetry"
call :EnableService "Diagnostic Execution Service"
call :EnableService "Diagnostic Policy Service"
call :EnableService "Diagnostic Service Host"
call :EnableService "Diagnostic System Host"
call :EnableService "Geolocation Service"
call :EnableService "IpHelper"
call :EnableService "Netlogon"
call :EnableService "Optimize Drives"
call :EnableService "Parental Controls"
call :EnableService "Phone Service"
call :EnableService "Remote Desktop Configuration"
call :EnableService "Remote Desktop Services Port Redirector"
call :EnableService "Sensor Service"
call :EnableService "Smart Card"
call :EnableService "Smart Card Device Enumerator"
call :EnableService "Smart Card Removal Policy"
call :EnableService "SysMain"
call :EnableService "Windows Biometric Service"
call :EnableService "Work Folders"

echo All specified services have been enabled.
pause
goto MENU

:DisableService
sc stop %~1 >nul 2>&1
if %errorlevel% equ 1060 (
    echo Service %~1 does not exist, skipping...
) else (
    sc config %~1 start= disabled
)
exit /b

:EnableService
sc config %~1 start= auto
sc start %~1 >nul 2>&1
if %errorlevel% equ 1060 (
    echo Service %~1 does not exist, skipping...
)
exit /b

No comments:

Post a Comment