I have a cmdexec step in a sql agent job that includes a redirection into a file at the end. It works as expected from a CMD shell running in the context of SQL Agent service account and produces a file in the desired location. If I run it as an agent job, however, the step 'succeeds' but never produces the output file. In both cases, the service account obviously has filesystem permissions and system rights sufficient to perform this action.

Is the cmdexec environment more restrictive in someway than just running cmd.exe?

  • 1
    How many lines are in the cmdexec jobstep? Just one command, or multiple? Aug 13, 2014 at 22:29

1 Answer 1


Go to the advanced tab for the step. Use one of the options to capture more output such as "Include step output in history" or the "Output File" setting. This should give you more information about the step and what is happening.

  • Accepting this as the answer. The big picture is that CMDEXEC is a WinAPI call that behaves a certain way. It's entirely different than starting a command shell. Sep 23, 2014 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.