Enable xp_cmdshell not working

I am trying to enable xp_cmdshellin SQL Server. So I ran:

EXEC master.dbo.sp_configure 'show advanced options', 1
RECONFIGURE
EXEC master.dbo.sp_configure 'xp_cmdshell', 1
RECONFIGURE 

The message that appears says:

The "show advanced options" configuration parameter has been changed from 1 to 1. Run the RECONFIGURE statement to install.

The configuration parameter "xp_cmdshell" was changed from 0 to 1. Run the RECONFIGURE statement to install.

Facet properties show "XPCmdShellEnabled"

However, when I perform

EXEC master..xp_cmdshell 'dir c:'

I got an error message

Msg 15281, 16, 1, xp_cmdshell, 1
SQL Server "sys.xp_cmdshell" "xp_cmdshell", . "xp_cmdshell" sp_configure. "xp_cmdshell" . " " SQL Server.

, Microsoft. ?

+4
2

: , .

--Disable
Use Master

GO
EXEC master.dbo.sp_configure 'xp_cmdshell', 0
RECONFIGURE WITH OVERRIDE

GO

EXEC master.dbo.sp_configure 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO

-- Enable
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
+10

SQL Server Management Studio :

  • Facets
  • Facet Surface Area Configuration
  • XPCmdShellEnabled True

enter image description here

+3

All Articles