cancel
Showing results for 
Search instead for 
Did you mean: 

Executing a batch file in BODS script does not work

Former Member
0 Kudos

Hi all,

I read so many posts about this topic and yet can't find the solution to my problem:

I want to execute a batch job that opens an excel file. The Code I use is:

exec('Batch_jobs\\CS_TOOL_BATCH.bat','', 8);

However the job starts but never finishes and the batch job also does not run.

Would be really appreciated if someone could help me


Thanks

Chris

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Chris

Have you tried changing that to

exec('cmd','Batch_jobs\\CS_TOOL_BATCH.bat', 8);

also provide the fully qualified path to the .bat file?

severin_thelen
Contributor
0 Kudos

Are you sure, that your script working correct?

What is the error code of your batch file?

Former Member
0 Kudos

Yes, there is no error code, it just says job is started and then nothing happens. it also does not stop.

former_member198401
Active Contributor
0 Kudos

Hi Chris,

What happens when you run the batch file from the command prompt on the job server. Does the batch file executes correctly without any errors.

Are there any macros in the excel file which calls another excel file

Regards

Arun Sasi

Former Member
0 Kudos

Hi Arun,

if I call the batch file from the command line there are no issues.

Yes the excel file has a macro that runs as soon as it opens that opens another excel file.

Chris

Former Member
0 Kudos

if the batch file open a program that requires user input then, in that case the job will hang since the job runs the process in background you will not see the application or message to acknowledge

so make sure there are no prompts or other application UI showing up etc.

when you run this batch file, if it open another excel in Excel program then check the task manager for process named excel and kill that, the job will continue


Former Member
0 Kudos

Hi Manoj,

The programm opened does not require any user input, if I just double click the batch job it runs as it should.

If I run the batch file via BODS and open the task manager there is no excel showing up. It is just as the batch file is never started.

Cheers

Chris

former_member198401
Active Contributor
0 Kudos

Hi Chris,

Can you try writing the VB script(macro) in a separate file (e.g.Task.vbs) and then call the VB macro through the exec() command

Let the script do the task independently

$G_SCRIPT_LOCATION ='\\\XYZ_Location\ Source';

exec('cscript','[$G_SCRIPT_LOCATION]\Task.vbs', 8);

Regards

Arun Sasi

former_member198401
Active Contributor
0 Kudos

Chris,

Any update

Regards

Arun Sasi

Former Member
0 Kudos

Good morning Arun,

the way via vb script seems to be the right way. With some more google help it seems that the issue lies within excel if you want the excel file to open another excel file. I think it is the same issue when running it via task scheduler. So I am working on this A Day in the Life: Excel: Running Excel on Windows Task Scheduler

to see if that is/was the issue. Will keep you posted.


Cheers

Chris

Former Member
0 Kudos

What is supposed to happen when the Excel file opens? If the job is executed as a user other than yourself it may be opening Excel and waiting for some user input on another desktop, which is why it neither fails or completes.

Former Member
0 Kudos

Hi Brian,

the excel file that opens is supposed to update another excel file and then send it to a distribution list via Excel. All happens on the server where BODS runs.