windows服務命令列檢視
查詢含有sql的服務名,分為SERVICE_NAME服務名和DISPLAY_NAME顯示名
C:\Windows\system32>sc query |findstr "SQL"
DISPLAY_NAME: SQL Server Integration Services 10.0SERVICE_NAME: MSSQLFDLauncher
DISPLAY_NAME: SQL Full-text Filter Daemon Launcher (MSSQLSERVER)
SERVICE_NAME: MSSQLSERVER
DISPLAY_NAME: SQL Server (MSSQLSERVER)
SERVICE_NAME: MSSQLServerOLAPService
DISPLAY_NAME: SQL Server Analysis Services (MSSQLSERVER)
DISPLAY_NAME: SQL Server Reporting Services (MSSQLSERVER)
SERVICE_NAME: SQLWriter
DISPLAY_NAME: SQL Server VSS Writer
檢視具體服務名的服務狀況
C:\Windows\system32>sc query MSSQLSERVER
SERVICE_NAME: MSSQLSERVER
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
關閉或啟動MSSQLSERVER服務
C:\Windows\system32>sc stop/start MSSQLSERVER
SERVICE_NAME: MSSQLSERVER
TYPE : 10 WIN32_OWN_PROCESS
STATE : 3 STOP_PENDING
(STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x1
WAIT_HINT : 0xea60
檢視服務sid具體狀態
C:\Windows\system32>sc showsid MSSQLSERVER
名稱: MSSQLSERVER
服務 SID: S-1-5-80-3880718306-3832830129-1677859214-2598158968-1052248003
狀態: 活動
檢視服務的具體配置資訊
C:\Windows\system32>sc qc MSSQLSERVER
[SC] QueryServiceConfig 成功
SERVICE_NAME: MSSQLSERVER
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn\sqlservr.exe" -sMSSQLSERVER
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : SQL Server (MSSQLSERVER)
DEPENDENCIES :
SERVICE_START_NAME : NT AUTHORITY\NETWORKSERVICE
檢視依賴MSSQLSERVER服務的服務
C:\Windows\system32>sc enumdepend MSSQLSERVER
[SC] EnumDependentServices: 讀取的項 = 1
SERVICE_NAME: SQLSERVERAGENT
DISPLAY_NAME: SQL Server 代理 (MSSQLSERVER)
TYPE : 10 WIN32_OWN_PROCESS
STATE : 1 STOPPED
WIN32_EXIT_CODE : 1077 (0x435)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0