Access denied for enabled xp_cmdshell for the admin user

Joshua H. picture Joshua H. · May 30, 2012 · Viewed 43.4k times · Source

I'm using xp_cmdshell within a database trigger to launch a exe file.

xp_cmdshell is enabled(it can execute simple cmd command like 'echo'). But when I try to launch the exe through xp_cmdshell, the access is denied.

I am the database administrator. And I can launch the exe through cmd directly. Anyone know why I get denied and how to fix it?

Answer

Peter Wishart picture Peter Wishart · May 30, 2012

Use xp_cmdshell to run "whoami", then check effective permissions for the stated user on the exe and any resources it accesses. Odds are that an account like localsystem is being used to run processes via xp_cmdshell.

EXEC xp_cmdshell 'whoami'