Enabling & Disabling xp_cmdshell in SQL SERVER


First we should configure the advance options, before configuring  for xp_cmdshell.

-- 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 

SELECT * FROM SYS.CONFIGURATIONS WHERE Name = 'show advanced options'

Disabling xp_cmdshell

EXEC sp_configure 'xp_cmdshell', 0
GO
RECONFIGURE
GO

-- Check the Disabled record.
SELECT * FROM SYS.CONFIGURATIONS WHERE Name = 'xp_cmdshell'

Enabling xp_cmdshell

EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO

-- Check the Enabled record.
SELECT * FROM SYS.CONFIGURATIONS WHERE Name = 'xp_cmdshell'

Thanks :)
Ebook Download
View all
Learn
View all