Created
April 21, 2017 22:02
-
-
Save hsed/fb6fbe26f1d0cf6d657c35c4a05e1fb9 to your computer and use it in GitHub Desktop.
Batch script to toggle Windows Update and Trusted Installer services.
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 /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