Sql-server – Sql Server Agent fails to run batch from desktop

sql serversql-server-agent

I’m using SQL Server 2008 and running a batch file from SQL Server Agent. The batch file is located in my desktop. When I try to run the job I get an error: “access is denied.” The batch file runs successfully if I run it manually. Also, the job runs successfully if I put the batch file anywhere in the C drive or F drive and run it from Agent. Any idea why the access is denied if the batch file is in desktop? The agent service account has the sysadmin server role in SQL Server. Thanks.

Best Answer

Any idea why the access is denied if the batch file is in desktop?

Yes. Because it is a rotten idea. The service agent account has no rights on your personal folders and your personal folders include the desktop. And you should keep it that way.

Your personal fodlers are btw., locked also for the admin accounts etc.

If you need sql agent to do something, I strongly suggest you agree on a location for that to happen and move the batch there.