使用sp_configure启用 'xp_cmdshell'?

EXEC sp_configure 'xp_cmdshell', 1,返回:配置选项 'xp_cmdshell' 不存在,也可能是高级选项。
最新回答
柒槿年

2021-01-11 10:54:28

两种方式启用xp_cmdshell

1.打开外围应用配置器—>

功能的外围应用配置器—>

实例名Database Enginexp_cmdshell—>

启用

2.sp_configure

-- 允许配置高级选项
EXEC sp_configure 'show advanced options', 1
GO
-- 重新配置
RECONFIGURE
GO
-- 启用xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 0
GO
--重新配置
RECONFIGURE
GO

--执行想要的xp_cmdshell语句
Exec xp_cmdshell 'query user'
GO

--用完后,要记得将xp_cmdshell禁用(从安全角度安全考虑)
-- 允许配置高级选项
EXEC sp_configure 'show advanced options', 1
GO
-- 重新配置
RECONFIGURE
GO
-- 禁用xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 1
GO
--重新配置
RECONFIGURE
GO
化妆去夜店∮

2023-10-05 14:25:15

EXEC sp_configure 'xp_cmdshell', 0

--------------------------
你是要启用啊,不好意思,那个启用是0
用高级选项需要先打开高级选项配置

-- 允许配置高级选项
EXEC sp_configure 'show advanced options', 1
GO
-- 重新配置
RECONFIGURE
GO
-- 启用xp_cmdshell
EXEC sp_configure 'xp_cmdshell', 0
GO
--重新配置
RECONFIGURE
GO