SQL SERVER – Enable xp_cmdshell using sp_configure
Posted in Microsoft, SQL Server
if you receive the following message, read on..
Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
SQL Server blocked access to procedure ‘sys.xp_cmdshell’ of component ‘xp_cmdshell’ because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of ‘xp_cmdshell’ by using sp_configure. For more information about enabling ‘xp_cmdshell’, see "Surface Area Configuration" in SQL Server Books Online.
Start a SSMS (Microsoft SQL Server Management Studio), open a New Query Window and do the following:
Paste this and execute it using F5
EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 0
GO
RECONFIGURE
GO
to check if it’s configured properly, use this extended stored procedure:
xp_cmdshell 'dir *.exe'