Page 1 of 1

Need to run a batch file from Macro Scheduler

Posted: 02 May 2017 10:05
by cyberic68
I i'm trying to successfully run a batch job from Marco Scheduler software (task scheduler)

When I double click on my batch file to run it, it works perfectly. but It gives me this error when I'm trying to run it from my task scheduler software (Macro Scheduler).

Here's my batch file, it calls the mogify.exe executable from ImageMagick apps

-------------------------------------

@echo off
set IMDIR="C:\Program Files\ImageMagick-7.0.5-Q16"
set WORKINGDIR="C:\Private\overviews\bkp_ext"
set OUTPUTDIR="Z:\transportation\xfiles\bi\test\overviews\montreal"

pushd %WORKINGDIR%

%IMDIR%\mogrify.exe -gravity south -splice 0x20 -pointsize 16 ^
-annotate +0+33 "%%[t]%%[e]" -path %OUTPUTDIR% -format jpg "*._*"

------------------------------------

Here's the error message when it run via Marco Scheduler

C:\WINDOWS\system32>"C:\Program Files\ImageMagick-7.0.5-Q16\"mogrify.exe -gravit
y south -splice 0x20 -pointsize 16 -annotate +0+33 "%[t]%[e]" -format jpg "R:\Pr
ivate\overviews\bkp_ext\*._*"
mogrify.exe: unable to open image 'jpg:': Invalid argument @ error/blob.c/OpenBl
ob/3094.
mogrify.exe: unrecognized image format `jpg' @ error/mogrify.c/MogrifyImageComma
nd/4936.

Any help would be appreciated

Thanks
Eric

Re: Need to run a batch file from Macro Scheduler

Posted: 02 May 2017 13:09
by penpen
%IMDIR%\mogrify.exe -gravity south -splice 0x20 -pointsize 16 ^
-annotate +0+33 "%%[t]%%[e]" -path %OUTPUTDIR% -format jpg "*._*"
(...)
C:\WINDOWS\system32>"C:\Program Files\ImageMagick-7.0.5-Q16\"mogrify.exe -gravit
y south -splice 0x20 -pointsize 16 -annotate +0+33 "%[t]%[e]" -format jpg "R:\Pr
ivate\overviews\bkp_ext\*._*"
It seems you are not using the same command (batch vs macro start), so you don't just call the batch file.

Which program exactly, and how do you create and start the "Macro"?


penpen

Re: Need to run a batch file from Macro Scheduler

Posted: 02 May 2017 14:12
by cyberic68
Thanks for the reply, I problem is solved after rebooting my PC, I don't know why.

But for your information, my Macro Scheduler, was running my batch file with this internal command

Run>C:\BatchFiles\Overviews.bat

The content of my batch file "Overviews.bat" is

Code: Select all

@echo off
set IMDIR="C:\Program Files\ImageMagick-7.0.5-Q16"
set WORKINGDIR="C:\Private\overviews\bkp_ext"
set OUTPUTDIR="Z:\transportation\xfiles\bi\test\overviews\montreal"

pushd %WORKINGDIR%

%IMDIR%\mogrify.exe -gravity south -splice 0x20 -pointsize 16 ^
-annotate +0+33 "%%[t]%%[e]" -path %OUTPUTDIR% -format jpg "*._*"



And the error that I was receiving was

C:\WINDOWS\system32>"C:\Program Files\ImageMagick-7.0.5-Q16\"mogrify.exe -gravit
y south -splice 0x20 -pointsize 16 -annotate +0+33 "%[t]%[e]" -format jpg "R:\Pr
ivate\overviews\bkp_ext\*._*"
mogrify.exe: unable to open image 'jpg:': Invalid argument @ error/blob.c/OpenBl
ob/3094.
mogrify.exe: unrecognized image format `jpg' @ error/mogrify.c/MogrifyImageComma
nd/4936.

Before I reeboot my PC I have tried to remove the double quote at the end of the batch file where the instruction was trying to open the multiple image that I have in the folder

"*._*" with only *._* then it work

but after the reboot, I have put back the double quote "*._*" and it worked again (strange)

Thanks
Eric

Re: Need to run a batch file from Macro Scheduler

Posted: 02 May 2017 14:22
by igor_andreev
Sheduler invoked task from 'System' account? Looks like sheduler does not have rights to the network share. And folder was changed to system32 by default.

Try add errorlevel after PUSHD, eg:

Code: Select all

pushd %WORKINGDIR%
if errorlevel 1 echo pushd error>c:\error.txt

and run from scheduler again. If file c:\error.txt exist - you must run sheduled task as logged user. See settings in Scheduler.

What is R:\, Z:\ ? Mapped drives, USB?