15 years ago I was able to create a Windows service which ran a script to move C:\Program Files to another disk and created a NTFS junction to point to the new location.

Now I’m trying to do the same with current Windows versions.


.

I started to look into this matter again when I found this description of the ServiceGroupOrder:
http://superuser.com/a/448611

Service Control Manager
https://msdn.microsoft.com/en-us/library/windows/desktop/ms685150%28v=vs.85%29.aspx

Automatically Starting Services
https://msdn.microsoft.com/en-us/library/windows/desktop/ms681957%28v=vs.85%29.aspx

GroupOrderList
https://technet.microsoft.com/en-us/library/cc976063.aspx

What Happens to File Systems During System Boot
https://msdn.microsoft.com/en-us/library/windows/hardware/ff557280%28v=vs.85%29.aspx

Load Order Groups for File System Filter Drivers
https://msdn.microsoft.com/en-us/library/windows/hardware/ff549694%28v=vs.85%29.aspx

How To Control Device Driver Load Order
https://support.microsoft.com/en-us/kb/115486

Windows Services Frequently Asked Questions (FAQ)
http://www.coretechnologies.com/WindowsServices/FAQ.html

13 How do I add a dependency to a service?
http://www.coretechnologies.com/WindowsServices/FAQ.html#AddADependency

Understanding System Configuration
https://technet.microsoft.com/en-us/library/cc731226.aspx

Service State Transitions
https://msdn.microsoft.com/en-us/library/windows/desktop/ee126211%28v=vs.85%29.aspx

PsTools
https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

NSSM – the Non-Sucking Service Manager
http://www.nssm.cc/

The HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder subkey determines the order in which Service Groups are loaded. The List value is a REG_MULT_SZ entry that specifies the Service Group order.

C:\Windows\system32>reg query HKLM\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder /v List

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ServiceGroupOrder
    List    REG_MULTI_SZ    
System Reserved
EMS
WdfLoadGroup
Boot Bus Extender
System Bus Extender
SCSI miniport
Port
Primary Disk
SCSI Class
SCSI CDROM Class
FSFilter Infrastructure
FSFilter System
FSFilter Bottom
FSFilter Copy Protection
FSFilter Security Enhancer
FSFilter Open File
FSFilter Physical Quota Management
FSFilter Virtualization
FSFilter Encryption
FSFilter Compression
FSFilter Imaging
FSFilter HSM
FSFilter Cluster File System
FSFilter System Recovery
FSFilter Quota Management
FSFilter Content Screener
FSFilter Continuous Backup
FSFilter Replication
FSFilter Anti-Virus
FSFilter Undelete
FSFilter Activity Monitor
FSFilter Top
Filter
Boot File System
Base
Pointer Port
Keyboard Port
Pointer Class
Keyboard Class
Video Init
Video
Video Save
File System
Streams Drivers
NDIS Wrapper
COM Infrastructure
Event Log
ProfSvc_Group
AudioGroup
UIGroup
MS_WindowsLocalValidation
PlugPlay
Cryptography
PNP_TDI
NDIS
TDI
iSCSI
NetBIOSGroup
ShellSvcGroup
SchedulerGroup
SpoolerGroup
SmartCardGroup
NetworkProvider
MS_WindowsRemoteValidation
NetDDEGroup
Parallel arbitrator
Extended Base
PCI Configuration
MS Transactions

The HKEY_LOCAL_MACHINE\CurrentControlSet\Control\GroupOrderList subkey determines the order in which services within a Service Group are loaded. Services in a Service Group are assigned a tag, a unique numeric value within a Service Group which determines the service load order. Each value entry in GroupOrderList represents a Service Group. The value of the entry is a series of tags in a specified order. The first entry in this REG_BINARY value is the number of services in the group, followed by the tags in load sequence. If you look at PointerPort you can see that there are 4 services in the group and that the service with tag 01 is loaded first, followed by the service with tag 02, 03 and 04.

C:\Windows\system32>reg query HKLM\SYSTEM\CurrentControlSet\Control\GroupOrderList


HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\GroupOrderList
    FSFilter System    REG_BINARY    0100000001000000
    Video    REG_BINARY    06000000010000000200000003000000040000000500000006000000
    FSFilter Physical Quota Management    REG_BINARY    0100000001000000
    FSFilter Replication    REG_BINARY    0100000001000000
    FSFilter Undelete    REG_BINARY    0100000001000000
    FSFilter System Recovery    REG_BINARY    0100000001000000
    FSFilter Content Screener    REG_BINARY    0100000001000000
    Video Save    REG_BINARY    0100000001000000
    FSFilter Infrastructure    REG_BINARY    0100000001000000
    FSFilter Continuous Backup    REG_BINARY    0100000001000000
    FSFilter Imaging    REG_BINARY    0100000001000000
    Parallel arbitrator    REG_BINARY    020000000100000002000000
    PNP_TDI    REG_BINARY    0700000005000000010000000200000003000000040000000600000007000000
    FSFilter Top    REG_BINARY    0100000001000000
    Streams Drivers    REG_BINARY    0100000001000000
    Pointer Class    REG_BINARY    0100000001000000
    SCSI Class    REG_BINARY    0400000001000000020000000300000004000000
    FSFilter Encryption    REG_BINARY    0100000001000000
    FSFilter Activity Monitor    REG_BINARY    0100000001000000
    FSFilter Compression    REG_BINARY    0100000001000000
    Keyboard Class    REG_BINARY    0100000001000000
    FSFilter Bottom    REG_BINARY    0100000001000000
    FSFilter Quota Management    REG_BINARY    0100000001000000
    Filter    REG_BINARY    0100000001000000
    Network    REG_BINARY    06000000010000000200000003000000040000000500000006000000
    EMS    REG_BINARY    0100000001000000
    SCSI CDROM Class    REG_BINARY    03000000010000000200000003000000
    Keyboard Port    REG_BINARY    050000000100000002000000030000000400000005000000
    Pointer Port    REG_BINARY    0400000001000000020000000300000004000000
    FSFilter Security Enhancer    REG_BINARY    0100000001000000
    SCSI Miniport    REG_BINARY    59000000000100000101000019000000010000000200000003000000040000000
    FSFilter Cluster File System    REG_BINARY    0100000001000000
    Boot Bus Extender    REG_BINARY    0B00000007000000010000000200000003000000040000000500000006000
    FSFilter HSM    REG_BINARY    0100000001000000
    FSFilter Anti-Virus    REG_BINARY    0100000001000000
    Cryptography    REG_BINARY    020000000100000002000000
    Base    REG_BINARY    1C0000000E0000000100000002000000030000000400000005000000060000000700000008
    FSFilter Open File    REG_BINARY    0100000001000000
    NetBIOSGroup    REG_BINARY    020000000100000002000000
    Extended Base    REG_BINARY    34000000010000000200000004000000030000000500000006000000070000000
    SpoolerGroup    REG_BINARY    020000000100000002000000
    System Bus Extender    REG_BINARY    190000000700000003000000040000000100000008000000090000000A0
    PnP Filter    REG_BINARY    09000000010000000300000004000000020000000500000006000000070000000800
    Ndis    REG_BINARY    1C000000010000000200000003000000040000000500000006000000070000000800000009
    FSFilter Virtualization    REG_BINARY    0100000001000000
    Video Init    REG_BINARY    0100000001000000
    FSFilter Copy Protection    REG_BINARY    0100000001000000
    Primary Disk    REG_BINARY    050000000100000002000000030000000400000005000000

To list services of each service group, open a CMD prompt as Administrator and run the following batch file:

@echo off

setlocal enabledelayedexpansion

for /f "tokens=1,2,3,4,5 skip=2" %%a in ('reg query HKLM\SYSTEM\CurrentControlSet\Control\GroupOrderList') do (
    if "%%e" EQU "REG_BINARY" set serviceName=%%a %%b %%c %%d
    if "%%d" EQU "REG_BINARY" set serviceName=%%a %%b %%c
    if "%%c" EQU "REG_BINARY" set serviceName=%%a %%b
    if "%%b" EQU "REG_BINARY" set serviceName=%%a
        
    echo !serviceName!
    echo ---------------------------------------------------------------------------------

    echo Command: reg query HKLM\SYSTEM\CurrentControlSet\Control\GroupOrderList /v "!serviceName!"
    echo Output:
    reg query HKLM\SYSTEM\CurrentControlSet\Control\GroupOrderList /v "!serviceName!"
    
    echo Command: sc query type= all group= "!serviceName!"
    echo Output:
    sc query type= all group= "!serviceName!"
        
    set serviceName=
    echo.
)

The following script lists the other Windows services and their load order groups:

@echo off

rem
rem pipe the service short names from sc query to sc qc %%i
rem

sc query | findstr "SERVICE_NAME" | for /f "tokens=2" %%i in ('more') do @sc qc %%i | findstr "SERVICE_NAME LOAD_ORDER_GROUP TAG DISPLAY_NAME"
C:\Windows\system32>sc qc eventlog
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: eventlog
        TYPE               : 20  WIN32_SHARE_PROCESS
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : C:\Windows\System32\svchost.exe -k LocalServiceNetworkRestricted
        LOAD_ORDER_GROUP   : Event Log
        TAG                : 0
        DISPLAY_NAME       : Windows Event Log
        DEPENDENCIES       :
        SERVICE_START_NAME : NT AUTHORITY\LocalService
C:\Windows\system32>sc qc dcomlaunch
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: dcomlaunch
        TYPE               : 20  WIN32_SHARE_PROCESS
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 1   NORMAL
        BINARY_PATH_NAME   : C:\Windows\system32\svchost.exe -k DcomLaunch
        LOAD_ORDER_GROUP   : COM Infrastructure
        TAG                : 0
        DISPLAY_NAME       : DCOM Server Process Launcher
        DEPENDENCIES       :
        SERVICE_START_NAME : LocalSystem
Advertisements