xp_cmdshell选项是一个 SQL Server 服务器配置选项,使系统管理员能够控制是否可以在系统上执行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