Categories
Sql Server

How To Enable and Disable XP_CMDSHELL Using SP_CONFIGURE

How To Enable and Disable XP_CMDSHELL Using SP_CONFIGURE

In this article we will discussĀ How To Enable and Disable XP_CMDSHELL Using SP_CONFIGURE.The xp_cmdshell option is a server configuration option that enables system administrators to control whether the xp_cmdshell extended stored procedure can be executed on a system.In order to use XP_CMDSHELL you need to be a system administrator.

Query To Enable 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

Query To Disable 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', 0
RECONFIGURE WITH OVERRIDE
GO