CmdExec for delete and xcopy job failing with Access denied

  • Hi,

    I am trying to create a job with CmdExec that will call the batchfile. The batchfile has following commands:

    echo new text>\\g1\sharedick\report\rpt_upload.log

    echo on

    echo delete files>>\\g1\sharedick\report\rpt_upload.log

    del \\x1\online\reports\*.pdf /F/Q>>\\g1\sharedick\report\rpt_upload.log

    echo copy files to case>>\\g1\sharedick\report\rpt_upload.log

    xcopy \\g1\sharedick\Reports\*.pdf \\x1\online\reports\ /H/Q/Y/R>>\\g1\sharedick\report\rpt_upload.log

    When i run the job it shows job ran successfully, however i dont see any files being deleted or copied. Checking the log it shows Access denied for the user running the sql server agent job. I had comfirmed that that user had the full control on both shared drives and folders.

    we are using sql sever 2005 32 bit standard edition with SP2.

    Thanks

  • The rights are those of the job, or agent, running the job. Not the user that runs the job. You can specify a proxy account for SQL Agent, but if it's not there, the SQL Agent service account is what needs rights.

  • I mean.. sql server agent serveices has the full rights on both shared disk.

  • The user must not have rights. Access denied is a simple message. Do you have a domain user running the Agent? Can you log in as this user and execute the batch file?

    I might also try creating a file. A simple "echo 'test' > newfile.txt" and see if that works on each disk.

  • Yes! we have the same domain user running the all sql agent services. I have output the command to .txt file. The output file shows all commands are executed successfully. However, in sql job logs it show XXX\XYZ .....Access Denied.

  • That's strange. Are you sure that the rights cover those files? Perhaps there's something weird with them?

    Can you log in as the domain user running the Agent?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply