Search code examples
sql-servert-sqlxp-cmdshell

SQL Server xp_cmdshell error 5


When I execute the following statement in SQL Server 2008:

declare @s varchar(100)
set @s='dir'
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'xp_cmdshell',1
reconfigure
exec xp_cmdshell @s

It gives the following error:

execute xp_cmdshell error.invoke 'CreateProcess' failed,error code: '5'.

How can I fix this? I enabled the xp_cmdshell procedure, and I have given the folder read-write privileges.

I searched on the internet and tips to add domain user to the Administrator Group. But I still do not understand the principle. I would appreciate any insights. Thanks!


Solution

  • Error code 5 means - access denied.

    Please check if account which used for MSSQL service has right on command that you trying to run.

    Details: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/bbdffb3c-6604-4011-ac5f-5ea8ecb1a32c/xpcmdshell-a-call-to-createprocess-failed-with-error-code-5-under-sql2005-rtm?forum=sqlsecurity