1

I have this step in sql server job enter image description here

AAA.bat content is this

call BBB.bat
call CCC.bat

BBB.bat and CCC.bat each run ETL packages. When I run above step it throws error

BBB.bat is not recognized as an internal or external command, operable program or batch file... CCC.bat is not recognized as an internal or external command, operable program or batch file

However, when I replace AAA.bat with either BBB.bat or CCC.bat it works as intended.

Eric Klaus
  • 923
  • 1
  • 9
  • 24
  • Call the `bat` files with their full (UNC) path. But why a batch file? Wouldn't you be better off with Powershell? Batch is pretty dated now. – Thom A Feb 17 '20 at 16:37
  • @Larnu - While I would agree that getting onto PowerShell is a good idea, it would not change anything about this problem. The issue is the PATH to the executable, regardless of whether it is .bat, .ps1, .py, .pl, .exe, or anything else. – lit Feb 18 '20 at 14:19
  • @lit I mention the paths of the at the start of my comment. *"Call the `bat` files with their full (UNC) path"* – Thom A Feb 18 '20 at 14:33

1 Answers1

1

Are BBB.bat and CCC.bat in the same directory as AAA.bat? You need to set the working directory first. In AAA.bat add the following at the top of the file:

cd /d D:\Path\Client1

Or, call BBB.bat and CCC.bat using their full path.

A possibly better solution, depending on your environment and needs, would be to have your job contain two steps, each one calling the appropriate batch file (BBB or CCC) separately. That way, if you have a failure, its very obvious which batch file had a problem.

Dale K
  • 25,246
  • 15
  • 42
  • 71
  • AAA, BBB and CCC have same path. Is it possible to do it without setting path? Since i'm going to have many other jobs for Client2, Client3, etc. – Eric Klaus Feb 17 '20 at 17:12
  • I though maybe there is command which will set directory to the directory where current file (aaa) is – Eric Klaus Feb 17 '20 at 18:07