Skip to content

Instantly share code, notes, and snippets.

@hsed
Created April 21, 2017 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hsed/fb6fbe26f1d0cf6d657c35c4a05e1fb9 to your computer and use it in GitHub Desktop.
Save hsed/fb6fbe26f1d0cf6d657c35c4a05e1fb9 to your computer and use it in GitHub Desktop.
Batch script to toggle Windows Update and Trusted Installer services.
@echo off
set /a timeoutsec=3
title WU+TI-Toggle v0.2-a by Haaris
color 0a
echo Description: Script to toggle Windows Update and Trusted Installer services.
echo;
echo Checking status...
sc query "wuauserv" | findstr RUNNING
if %ERRORLEVEL% == 2 goto trouble
if %ERRORLEVEL% == 1 goto stopped
if %ERRORLEVEL% == 0 goto started
echo Unknown Status
goto end
:trouble
echo Cannot perform operation, please run script with admin privileges.
echo Exiting in 10s...
set /a timeoutsec=10
goto end
:started
echo Stopping services...
sc config "wuauserv" start= disabled
sc config "TrustedInstaller" start= disabled
net stop wuauserv
net stop TrustedInstaller
if %ERRORLEVEL% == 2 goto trouble
if %ERRORLEVEL% == 0 echo Services stopped and disabled
goto end
:stopped
echo Starting services...
sc config "wuauserv" start= demand
sc config "TrustedInstaller" start= demand
net start wuauserv
net start TrustedInstaller
echo;
if %ERRORLEVEL% == 2 goto trouble
if %ERRORLEVEL% == 0 echo Services started and enabled
echo Please open windows update in settings to update your computer.
pause
goto end
:end
timeout %timeoutsec%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment