• Have you tried putting your code in a stored procedure and using the "EXECUTE AS" option in that stored procedure so that it executes as a user who is permitted to run xp_cmdshell ?