trying to run an Batch file from a Job

  • Hi,

    I looked on the web and I just found the cod that I have below to run a batch file.

    But it does not work, when I look at view history of the jobs it says it ran successfully, but it does do anything.

    If I run the batch file directly it works perfectly. I need it in a job because I want to secdual it to run every 15 minutes.

    Any ideas of what is happening or what I can do to run the batch file from the job?

    Thank you

    My code in the job

    cmd.exe /c "C:\Scripts\FileTimeFilterJS.bat"
  • As a random guess (I can't see the code in your bat file), it is either using relative paths OR is using network shared drives.

    Since SQL says it ran successfully, it is VERY likely that it ran to completion.  What you could do is add some logging into your bat file so you can tell what has been run and were it ran into problems.  Inside your bat file, you can redirect all errors to a file and all output to a file.  This will help you in debugging what went wrong.

    Another possible problem could be permissions as that bat file is being run as the SQL Server Agent Service account, not as you.  So running the bat file as yourself doesn't really tell you anything that useful.

    An alternate way to run it where you can have more control over who is running it would e to use windows task scheduler.  Depending on your needs, this may or may not work for you.

  • As far as the file path in the script it has a path like this C:\scripts\file.bat.

    the file has Service account permissions in it.

    Thank you


  • running the script from C:\ though is different than running it from c:\temp or any other folder.  If "file.bat" is using relative paths instead of absolute paths, it may be that it can't find a file/folder it is looking for.

Viewing 4 posts - 1 through 4 (of 4 total)

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