Backup Windows 10 Services Startup Type Configuration

After doing a fresh install of Windows 10, disabling unused Windows Services is one of the time-consuming tasks you perform. Once configured, you can back up the service startup state using a Script so that it can be used for subsequent installations or if you need to automate the task on several computers.

Services state backups can also help when you troubleshoot Windows services and want to quickly rollback the changes you made.

Backup Services Configuration (Startup Type) in Windows

Here is a Windows Services startup configuration backup VBScript which I wrote. The script backs up the startup state of all Services by outputting the services configuration in two file formats — .reg (registration entries) and .bat (Windows Batch file) for you to restore the services configuration later.

'Description: This script backs up the Windows Services startup configuration to a REG file.
'For Windows 10, Windows Server 2016
'© 2016-2019  Ramesh Srinivasan
'Website: https://www.winhelponline.com/blog/
'Revised: Jul 07, 2019

Option Explicit
If WScript.Arguments.length = 0 Then
   Dim objShell : Set objShell = CreateObject("Shell.Application")
   objShell.ShellExecute "wscript.exe", Chr(34) & _
   WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
Else   
   Dim WshShell, objFSO, strNow, intServiceType, intStartupType, strDisplayName, iSvcCnt
   Dim sREGFile, sBATFile, r, b, strComputer, objWMIService, colListOfServices, objService   
   Set WshShell = CreateObject("Wscript.Shell")
   Set objFSO = Wscript.CreateObject("Scripting.FilesystemObject")
   
   strNow = Year(Date) & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2)
   
   Dim objFile: Set objFile = objFSO.GetFile(WScript.ScriptFullName)  
   sREGFile = objFSO.GetParentFolderName(objFile) & "\svc_curr_state_" & strNow & ".reg"
   sBATFile = objFSO.GetParentFolderName(objFile) & "\svc_curr_state_" & strNow & ".bat"
   
   Set r = objFSO.CreateTextFile (sREGFile, True)
   r.WriteLine "Windows Registry Editor Version 5.00"
   r.WriteBlankLines 1
   r.WriteLine ";Services Startup Configuration Backup " & Now
   r.WriteBlankLines 1
   
   Set b = objFSO.CreateTextFile (sBATFile, True)
   b.WriteLine "@echo Restore Service Startup State saved at " & Now
   b.WriteBlankLines 1
   
   strComputer = "."
   iSvcCnt=0
   Dim sStartState, sSvcName, sSkippedSvc
   
   Set objWMIService = GetObject("winmgmts:" _
   & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
   
   Set colListOfServices = objWMIService.ExecQuery _
   ("Select * from Win32_Service")
   
   For Each objService In colListOfServices
      iSvcCnt=iSvcCnt + 1
      r.WriteLine "[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\" & trim(objService.Name) & "]"
      sStartState = lcase(objService.StartMode)
      sSvcName = objService.Name
      Select Case sStartState
         Case "boot"
         
         r.WriteLine chr(34) & "Start" & Chr(34) & "=dword:00000000"
         b.WriteLine "sc.exe config " & sSvcName & " start= boot"
         
         Case "system"
         r.WriteLine chr(34) & "Start" & Chr(34) & "=dword:00000001"
         b.WriteLine "sc.exe config " & sSvcName & " start= system"
         
         Case "auto"
         'Check if it's Automatic (Delayed start)
         r.WriteLine chr(34) & "Start" & Chr(34) & "=dword:00000002"     
         If objService.DelayedAutoStart = True Then
            r.WriteLine chr(34) & "DelayedAutostart" & Chr(34) & "=dword:00000001"
            b.WriteLine "sc.exe config " & sSvcName & " start= delayed-auto"
         Else
            r.WriteLine chr(34) & "DelayedAutostart" & Chr(34) & "=-"
            b.WriteLine "sc.exe config " & sSvcName & " start= auto"
         End If
         
         Case "manual"
         
         r.WriteLine chr(34) & "Start" & Chr(34) & "=dword:00000003"
         b.WriteLine "sc.exe config " & sSvcName & " start= demand"
         
         Case "disabled"
         
         r.WriteLine chr(34) & "Start" & Chr(34) & "=dword:00000004"
         b.WriteLine "sc.exe config " & sSvcName & " start= disabled"
         
         Case "unknown"	sSkippedSvc = sSkippedSvc & ", " & sSvcName
         'Case Else
      End Select
      r.WriteBlankLines 1
   Next
   
   If trim(sSkippedSvc) <> "" Then
      WScript.Echo iSvcCnt & " Services found. The services " & sSkippedSvc & " could not be backed up."
   Else
      WScript.Echo iSvcCnt & " Services found and their startup configuration backed up."
   End If
   
   r.Close
   b.WriteLine "@pause"
   b.Close
   WshShell.Run "notepad.exe " & sREGFile
   WshShell.Run "notepad.exe " & sBATFile
   Set objFSO = Nothing
   Set WshShell = Nothing
End If

How to Use the VBScript?

  1. Copy the above lines of code to Notepad
  2. Save the file with .vbs extension — e.g., services_startup_config_backup.vbs.
  3. Double-click to run the script.

The script relaunches itself as administrator (elevated) and queries the list of Windows services and their startup type configuration. The results are written to .reg and .bat files for later restoration. The two files are created in the same folder as the script.

The output files will have the prefix svc_curr_state_ and then followed by the current date in yyyymmdd format — e.g., svc_curr_state_20190706.reg & svc_curr_state_20190706.bat

backup and restore windows services startup type configuration

Note: The script also takes into consideration whether a service is configured for a delayed start or not. For services with Automatic (delayed start) startup type, an additional registry value named DelayedAutoStart is used. If DelayedAutoStart is set to 1 and Start value is set to 2 (Automatic), then the service will be configured as Automatic (delayed start). And the Batch file will have the delayed-auto as the startup mode for those services.

Restoring the Services Startup type configuration

To restore the services startup type configuration from backup, choose one of the two formats.



.reg file

If you use the .reg file to restore the service startup preferences, you’ll need to restart Windows after applying the .reg file for the services configuration to refresh. This is the preferred method, though.

.bat file

The Batch file contains SC commands that will change the startup configuration of the services in real-time. You don’t require a restart if using the method. Make sure you run the Batch file from an admin Command Prompt window.

backup and restore windows services startup type configuration

Additional Notes

  1. For some services, you may encounter errors like [SC] ChangeServiceConfig FAILED 5: or similar. This is due to the service permissions or security descriptors which locks down services. In that case, you can launch a Command Prompt window as under the LOCALSYSTEM account and run the Batch file.
  2. In Windows 10, you can see many service names that have an underscore (_) and followed by some numbers. These numbers (suffix) may not match with that of other Windows 10 computers. Here are some examples:
    • AarSvc_8561415
    • BcastDVRUserService_8561415
    • BluetoothUserService_8561415
    • CaptureService_8561415
    • cbdhsvc_8561415
    • CDPUserSvc_8561415
    • ConsentUxUserSvc_8561415
    • CredentialEnrollmentManagerUserSvc_8561415
    • DeviceAssociationBrokerSvc_8561415
    • DevicePickerUserSvc_8561415
    • DevicesFlowUserSvc_8561415
    • LxssManagerUser_8561415
    • MessagingService_8561415
    • OneSyncSvc_8561415
    • PimIndexMaintenanceSvc_8561415
    • PrintWorkflowUserSvc_8561415
    • UnistoreSvc_8561415
    • UserDataSvc_8561415
    • WpnUserService_8561415

    The numbers suffix 8561415 in the above services (short) names may not be the same in other Windows 10 computers. That’s one thing you need to watch out for, when restoring the settings to another Windows 10 computer. Also, restoring these services using the SC.exe command may cause the error ChangeServiceConfig FAILED 87: The parameter is incorrect.

For older versions of Windows

For Windows versions earlier than Windows 10 (Windows Vista through Windows 8.1), use the script services_conf_backup.zip. Note that the older script doesn’t support Automatic (delayed start) start type — because of a WMI limitation. It treats Automatic and Automatic (delayed start) as the same.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support, my reader. It won't take more than 10 seconds of your time. The share buttons are right below. :)

About the author

Ramesh Srinivasan founded Winhelponline.com back in 2005. He is passionate about Microsoft technologies and he has been a Microsoft Most Valuable Professional (MVP) for 10 consecutive years from 2003 to 2012.

1 thought on “Backup Windows 10 Services Startup Type Configuration”

  1. hello,

    Can you please inverse date and adding time for best sort feature :

    Services_Backup_9162011.REG = bad

    Services_Backup_20110916-18h44.REG = best

    +

    For security reason AND control if i have bad sector hdd, please add SHA-1.

    For your vbs file …

    note : i create always a description file originalname(addversiondate).(originalextention).dsc.txt with extra infos ; (i use free download manager = FDM). Presently, i have only ScrapBook(ed) (a Firefox add-on), this web page with zip file.

    +

    bonus : Add maybe CRC32 in the name of the generated file ; example :

    Services_Backup_20110916-19h07(CRC32=12345678).REG = OK

    I use implbits . com / HashTab . aspx (Windows = V4.0 / Mac = V1.2).

    Thanks by advance and thank you for all your tools :))

    Reply

Leave a Comment