Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a SQL 2008 Agent job with a single Operating system (CmdExec) step:


Script.cmd runs a CS-Script.

If I run C:\Scripts\Script.cmd, everything appears fine - I get my expected logging output and echo %ERRORLEVEL% shows 0 afterwards.

When I run it through SqlAgent, though - I get my expected logging output and then

The system cannot find the file specified.  
Process Exit Code 1.  
The step failed.

The logging output is complete and correct, so it does run the batch file and the EXE that the batch file calls. The last thing the CS-Script does is:

Console.WriteLine("Exiting at 2009-09-22 16:10:32 with Status {0}", exitCode);
return (int)exitCode;

which is logged in the output, and in entirety.

What file can't it find?

share|improve this question
up vote 0 down vote accepted

Clearing CS-Script's cache did the trick. Procmon didn't really help, but did show hits to the user's cache folder in C:\Users\sql-agent-svc\AppData\Local\Temp\CSSCRIPT\Cache which prompted me to try clearing it.

Since it's a per-user cache, running CS-Script as an admin manually used a different cache which didn't have the issue.

As I understand it, the cache is only to avoid recompilation of an unchanged script - so it really shouldn't cause any issues. But, deleting it and letting CS-Script recreate it seems to have worked.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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