Windows Services

 

 


SC Command

 

# inquiry

# Default list all service

sc query [name]

# start / stop

i.e.

sc start dhcp

# config

# start= <boot|system|auto|demand|disabled|delayed-auto>

# "start= " 等號後必須要有空格

sc config dhcp start= auto

# To delete a service

sc delete "service name"

# config service auto start (auto, demand. or disabled)

sc config ServiceName start=auto

 


"delayed-auto" start

 

It will start shortly after all other services designated as Automatic have been started.(Default: 120 sec)

 

HKLM\SYSTEM\CurrentControlSet\services\<service name>\DelayedAutostart

the value 1 if delayed, 0 if not.

 

# Per-service
HKLM\SYSTEM\CurrentControlSet\services\<service name>\AutoStartDelay  (DWORD (32-bit)
                          or
# Global
HKLM\SYSTEM\CurrentControlSet\Control\AutoStartDelay  (DWORD (32-bit)

decimal number of seconds to wait

 


常見 Service

 

alg - application layer gateway service

spooler - Print Spooler

w32time - Windows Time

w3svc - iis

sharedaccess - Windows Firewall / Internet Connection Sharing (server 03)

 


Win7

 

winmgmt            # Disable 左佢, Services 的 Dependencies Tab 會廢左; tasklist, taskkill cmd 行唔到

 


Action

 

sc query xxx.exe | find /I "STATE" | find "STOPPED"
if errorlevel 1 goto :stop
goto :start

 

Creative Commons license icon Creative Commons license icon