如何启用xp_cmdshell
,为什么它被阻止或禁用?*
当启用时,您需要查看
的Permission部分xp_cmdshell MSDN docs:请点击链接
https://msdn.microsoft.com/en-us/library/ms190693.aspx
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO
xp_cmdshell-作为操作系统命令shell执行给定的命令字符串或批处理文件,并以文本行形式返回任何输出。
权限/权限: 只有SysAdmin固定角色可以执行
语法xp_cmdshell {' command_string '} [, no_output]参数
"command_string"是要在操作系统命令shell或DOS提示符中执行的命令字符串。Command_string为varchar(255)或nvarchar(4000),无默认值。
command_string不能包含多于一组双引号。
如果command_string引用的文件路径或程序名中存在空格,则必须使用一对引号。
如果在嵌入空格时遇到问题,可以考虑使用FAT 8.3文件名作为解决方法。
no_output
是可选参数executi
——允许修改高级选项。EXEC sp_configure 'show advanced options'去——更新当前配置的高级选项值。重新配置去现在禁用xp_cmdshell选项EXEC sp_configure 'xp_cmdshell', 0去重新配置去
查看更多信息——http://yrushka.com/index.php/sql-server/security/execute-remotely-t-sql-command-through-xp_cmdshell/
Use Master
GO
EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
GO