Script to Backup Current Start State (Startup Type) of Windows Services

»»»Script to Backup Current Start State (Startup Type) of Windows Services

There are hundreds of services that are installed and run in Windows operating system. Before changing the the settings of these services, such as configuration of Startup Type which determine whether Windows will load and start the services on system starts up, it’s best to backup and save the existing start state of all services, which can then be used to quickly restore all services to their original startup state when there is something goes wrong.

Services Start State Backup Script is a Windows command shell bath script that automatically export, save and backup all start state (the setting in Startup Type) of all services installed in Windows, into another new batch command script file with necessary commands to change the Startup Type of services with original value (or current start state value as when the backup script is created). The back up script, when execute and run, can automatically restore all services to their original start state as of when the file is backed up.

Download Services_Start_State_Backup.bat (extract from downloaded Services_Start_State_Backup.zip) (no longer available)

Note
You can create your own batch file to save the services’ start state by saving the following code into a file ending with .bat file extension.

TITLE Services Start State Backup Script by Tech Journey
@echo off
@echo ================================================================
@echo Windows Services Start State Backup Script (C) 2008 Tech Journey
@echo ================================================================
@echo.
@echo This script will backup all services with current state of Startup Type
@echo.
pause

REM Get current date and time
for /f "tokens=1, 2, 3, 4 delims=-/. " %%j in ('Date /T') do set FILENAME=Services_%%j_%%k_%%l_%%m
for /f "tokens=1, 2 delims=: " %%j in ('TIME /T') do set FILENAME=%FILENAME%_%%j_%%k.bat

REM Get all service name
sc query type= service state= all| findstr /r /C:"SERVICE_NAME:" >tmpsrv.txt
echo Saving Service Start State In %FILENAME% ...

REM save service start state into batch file
echo @echo Restore The Service Start State Saved At %TIME% %DATE% >"%FILENAME%"
echo @pause >>"%FILENAME%"

for /f "tokens=2 delims=:" %%j in (tmpsrv.txt) do @( sc qc %%j |findstr START_TYPE >tmpstype.txt && for /f "tokens=4 delims=:_ " %%s in (tmpstype.txt) do @echo sc config %%j start= %%s >>"%FILENAME%")
echo @pause >>"%FILENAME%"

del tmpsrv.txt
del tmpstype.txt

echo Services Start State Saved in %FILENAME%.
pause

Run the batch script to generate to services start state backup script. The generated back up batch script file will have the name in the form of Services_Day_DD_MM_YYYY_HH_MM.bat to avoid any accidental overwrite when user does multiple export or backup.

As and when the Startup Type state of all services in Windows requires to be restored and reset back to its earlier working state or value, simply run the generated .bat script on the time and date wanted. Note that when restoring, the batch script must be run as administrator in full priority elevation mode.

The script works in most Windows operating system such as Windows XP, Windows Vista, Windows 7, Windows 8, Windows 10, Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows Server 2016 or later.

By |2018-03-13T01:13:55+00:00March 13th, 2018|Categories: Windows|Tags: , , |10 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.