Search code examples
batch-filecmdimagemagickwindows-task-scheduler

.BAT script not running via Task Scheduler


I have an ImageMagick script in .bat format and have scheduled it via task scheduler to run under administrator.

The .bat works perfectly when running it normally, but Task Scheduler won't run it at all.

Anyone know why?

Script paste is below:

"C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe" H:\PD_IMAGES_BOXI\*.jpg ^
-set filename:name "%%t" ^
( -clone 0--1 -resize 400x400 -gravity center -background white -extent 400x400 +write "//termsvr3/d$/Program Files (x86)/SAP BusinessObjects/SAP BusinessObjects Enterprise XI 4.0/images/400-%%[filename:name].jpg" ) ^
( -clone 0--1 -resize 200x200 -gravity center -background white -extent 200x200 +write "//termsvr3/d$/Program Files (x86)/SAP BusinessObjects/SAP BusinessObjects Enterprise XI 4.0/images/200-%%[filename:name].jpg" ) ^
( -clone 0--1 -resize 100x100 -gravity center -background white -extent 100x100 +write "//termsvr3/d$/Program Files (x86)/SAP BusinessObjects/SAP BusinessObjects Enterprise XI 4.0/images/100-%%[filename:name].jpg" ) ^
null:
del "H:\PD_IMAGES_BOXI\*.jpg"

Solution

  • I managed to figure this one out. If you change the script file location or the time in the Scheduled Task menu, it seems to default back to the Local Administrator account rather than the Domain Admin account it was previously set to use. This is something I had overlooked. Changing it back now works perfectly with the file location changes & the double wild cards.