XP_CMDSHELL
In an effort to reduce the attack surface, in SQL 2005 upwards, XP_CMDSHELL is disabled by default.
To enable XP_CMDSHELL, in SQL 2005 or 2008, the following script will work..
EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO -- To enable xp_cmdshell EXEC sp_configure 'xp_cmdshell', 1 GO RECONFIGURE GO EXEC sp_configure 'show advanced options', 0 GO RECONFIGURE GO
Before it can be enabled, you need to allow the advanced options to changed which is what the ‘show advanced options’ does. This is then disabled afterwards.
To disable it, change the 1 to a 0 as below :-
EXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO -- To disable xp_cmdshell EXEC sp_configure 'xp_cmdshell', 0 GO RECONFIGURE GO EXEC sp_configure 'show advanced options', 0 GO RECONFIGURE GO
Advertisement