If you need to run T-SQL scripts/queries that utilize the xp_cmdshell stored procedure, SQL must be reconfigured to allow this:
Another thing to keep in mind is that the SQL Server service account must have permission to any files/folders that the stored procedure will create/modify/delete!