xp_cmdshell 選項

xp_cmdshell 選項是 SQL Server 2005 所推出的新功能,為伺服器的組態選項,可讓系統管理員控制 xp_cmdshell 擴充預存程序是否可在系統上執行。根據預設,xp_cmdshell 選項會在新安裝上停用,而且可以使用以原則為基礎的管理或執行 sp_configure 系統預存程序來啟用,如下列程式碼範例所示:

-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO