We were getting below error message when trying to execute xp_cmdshell within a stored procedure. Even though its dangerous I know but that’s how it was designed from application.
Error: "The EXECUTE permission was denied on the object ‘xp_cmdshell’, database ‘mssqlsystemresource’, schema ‘sys’"
To fix this In SSMS go to security ‡ Credentials ‡right click on “##xp_cmdshell_proxy##” ‡ You will get user name
We have to give this user execute permission
Syntax : GRANT EXECUTE ON xp_cmdshell TO [Domain\User]
Note : Make sure you must be using login on which you give execute permission. I found many times user do use diff id and complain.