Quick Bytes: Configuring XP_cmdshell and Agent XPs in SQL Server 2008
Here are ready to use SQL scripts
For Enabling XP_cmdshell:
USE
master
EXECUTE
sp_configure 'show advanced options', 1
RECONFIGURE
WITH OVERRIDE
GO
EXECUTE
sp_configure 'xp_cmdshell', '1' -- use 1 to enable it, 0 to disable it
RECONFIGURE
WITH OVERRIDE
GO
EXECUTE
sp_configure 'show advanced options', 0
RECONFIGURE
WITH OVERRIDE
GO
For Enabling Agent XPs:
USE master
EXECUTE
sp_configure 'show advanced options', 1
RECONFIGURE
WITH OVERRIDE
GO
EXECUTE
sp_configure 'Agent XPs', '1' -- use 1 to enable it, 0 to disable it
RECONFIGURE
WITH OVERRIDE
GO
EXECUTE
sp_configure 'show advanced options', 0
RECONFIGURE
WITH OVERRIDE
GO