Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Execute bat file from Database

fatehcis-JavaNetMay 2 2013 — edited May 6 2013
Hello,
I am using Oracle 11g2 SOE. I am trying to execute images.bat file using this code. but the Job get executed successfully, but the images.bat does not get executed. Any help please ?

First try
create or replace procedure resize_image (
p_script_name     in          varchar2
,  p_directory       in          varchar2
) as
begin
dbms_scheduler.create_job(
   'imgres'
 , job_action=>'C:\WINDOWS\system32\cmd.exe'
 , number_of_arguments=>3
 , job_type=>'executable'
 , enabled=>false);
dbms_scheduler.set_job_argument_value('imgres',1,'/q');
dbms_scheduler.set_job_argument_value('imgres',2,'/c');
dbms_scheduler.set_job_argument_value('imgres',3,p_directory||p_script_name);
dbms_scheduler.enable('imgres');
end;

begin
sys.resize_image('images.bat','C:\glassfish3\glassfish\domains\domain1\docroot\GNADS\');
end;
Scond try
begin
DBMS_SCHEDULER.create_job(
job_name => 'PROCESS_IMAGES',
job_type => 'executable',
job_action => 'C:\glassfish3\glassfish\domains\domain1\docroot\GNADS\images.bat',
start_date => SYSTIMESTAMP,
enabled => FALSE);
end;

BEGIN
    DBMS_SCHEDULER.RUN_JOB( 'PROCESS_IMAGES');
END;
Running this code, I can see that the Job was executed successfully
SELECT *
FROM DBA_scheduler_job_log
WHERE job_name = 'PROCESS_IMAGES'
 
Running this code, I can see that the Job was executed successfully
SELECT *
FROM DBA_scheduler_job_log
WHERE job_name = 'IMGRES'
 
Regards,
Fateh
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 3 2013
Added on May 2 2013
5 comments
223 views