problem running xp_cmdshell when Application Name set in connection string
the database(s) associated with the application should be trustworthy in order to access the machine's command line.

Try

select name,is_trustworthy_on from sys.databases;


if your target database is not trustworthy then:

alter database db_name set trustworthy on;


but beware the compromise to security