EXE Task Scheduler

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
markir
Newbie
Posts: 6
Joined: Mon Oct 25, 2021 4:28 pm

EXE Task Scheduler

Post by markir » Thu Feb 03, 2022 4:56 pm

I have a script that run successfully in the script editor as well as a scheduled task with the Macro Scheduler. It also works as an executable. When I run it in the Windows Task Scheduler it opens up the browser and navigates to the desired URL and then nothing else happens.

I even tried creating a batch file to execute the EXE and the having task scheduler execute the batch file. Same result.

I am running it from Task Scheduler because of other code that needs to run that I cannot do in Macro Scheduler. That code all works.

Any ideas?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: EXE Task Scheduler

Post by Dorian (MJT support) » Thu Feb 03, 2022 5:36 pm

Can you share that part of the script please, letting us know which parts are executing and where it seems to stop.
Yes, we have a Custom Scripting Service. Message me or go here

markir
Newbie
Posts: 6
Joined: Mon Oct 25, 2021 4:28 pm

Re: EXE Task Scheduler

Post by markir » Thu Feb 03, 2022 6:26 pm

// COMPILE_OPTS|C:\SUSD_SQLApps\MacroScheduler\MDLP_4-8_Progress\MDLP_4-8_Progress.exe||CONSOLE=1|INCLUDES=1| /NOSYSTRAY|RUNTIMES=1|BMPS=1
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

VBSTART
Sub MinimizeAll
Set oShellApp = CreateObject("Shell.Application")
oShellApp.MinimizeAll
End Sub
VBEND

Wait>5

VBRun>MinimizeAll

Let>CHROMEDRIVER_EXE=C:\SUSD_SQLApps\MacroScheduler\chromedriver.exe
Let>CHROMEDRIVER_OPTIONS=--start-maximized

ChromeStart>MDLP

Wait>10

ChromeNavigate>MDLP,url,https://www.mdlp.org/

Wait>10

!!!!!!!!!RUNS TO THIS POINT JUST FINE!!!!!!!!!!!!!!!!!!!!

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif

Wait>5

ChromeFindElements>MDLP,name,user_ID,elements
ChromeSetElementValue>MDLP,elements_2,[USERNAME]
ChromeFindElements>MDLP,name,user_pwd,pwd
ChromeSetElementValue>MDLP,pwd_2,[PASSWORD]

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_2.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif

Wait>5

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_3.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif

Wait>5

!!!!!!!!!PICKS UP HERE BUT FAILS BECAUSE IT WAS NOT ABLE TO LOGIN!!!!!!!!!!!!!!!!!!!!


ChromeNavigate>MDLP,url,https://www.mdlp.org/staff/query_engine/index.php


Wait>5
//STUDENT ID
ChromeFindElements>MDLP,id,Student_ID,elements_c
ChromeElementAction>MDLP,elements_c_1,click

//STUDENT Name
ChromeFindElements>MDLP,id,Student_Name,elements_sn
ChromeElementAction>MDLP,elements_sn_1,click

//STUDENT Grade Level
ChromeFindElements>MDLP,id,Student_Grade_Level,elements_gl
ChromeElementAction>MDLP,elements_gl_1,click

//STUDENT Status
ChromeFindElements>MDLP,id,Stud_Status,elements_ss
ChromeElementAction>MDLP,elements_s_1,click

//STUDENT Course Dates
ChromeFindElements>MDLP,id,Course_Dates,elements_cd
ChromeElementAction>MDLP,elements_cd_1,click

//STUDENT Course_Name
ChromeFindElements>MDLP,id,Course_Name,elements_cn
ChromeElementAction>MDLP,elements_cn_1,click

//STUDENT Teacher_Name
ChromeFindElements>MDLP,id,Teacher_Name,elements_tn
ChromeElementAction>MDLP,elements_tn_1,click

//STUDENT Course_Status
ChromeFindElements>MDLP,id,Course_Status,elements_cs
ChromeElementAction>MDLP,elements_cs_1,click

//STUDENT Course_Progress
ChromeFindElements>MDLP,id,Course_Progress,elements_cp
ChromeElementAction>MDLP,elements_cp_1,click

//STUDENT Grade_Earned
ChromeFindElements>MDLP,id,Grade_Earned,elements_ge
ChromeElementAction>MDLP,elements_ge_1,click

//STUDENT downloadCSV
ChromeFindElements>MDLP,id,downloadCSV,elements_dc
ChromeElementAction>MDLP,elements_dc_1,click

//COURSE STATUS
ChromeFindElements>MDLP,id,searchCourseStatus,scs
ChromeSetElementValue>MDLP,scs_1,notDropped

//GetDate>Todaysdate
//DateAdd>Todaysdate,D,-1,Prev_Sun
//DateAdd>Todaysdate,D,-8,Prev_Sun2

//START DATE
//ChromeFindElements>MDLP,id,searchStart,ss
//ChromeSetElementValue>MDLP,ss_1,Prev_Sun2

//END DATE
//ChromeFindElements>MDLP,id,searchStart,ss2
//ChromeSetElementValue>MDLP,ss2_1,Prev_Sun

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_6.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif

Wait>15

VBRun>MinimizeAll

ChromeQuit>MDLP

markir
Newbie
Posts: 6
Joined: Mon Oct 25, 2021 4:28 pm

Re: EXE Task Scheduler

Post by markir » Thu Feb 03, 2022 10:28 pm

Its not interacting with the contents of the window at all. I added this Message code and it shows up when I run the EXE from command prompt. But does not when run from Task Scheduler.

FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0

Message>Found Log In

MouseMove>XArr_0,YArr_0
LClick
Endif

I even tried this:

https://www.itsupportguides.com/knowled ... ractively/

markir
Newbie
Posts: 6
Joined: Mon Oct 25, 2021 4:28 pm

Re: EXE Task Scheduler

Post by markir » Thu Feb 03, 2022 11:05 pm

Tried this:

MouseMove>1491,132
LClick

//Find and Left Click Center of
//FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
//If>NumFound>0

//Message>Found Log In

//MouseMove>XArr_0,YArr_0
//LClick
//Endif

Works in cmd prompt does not move the mouse in Task Scheduler.

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1380
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: EXE Task Scheduler

Post by Dorian (MJT support) » Fri Feb 04, 2022 11:02 am

I can't replicate this at all. It successfully runs through to entering the username even if run through Task Scheduler. All the usual reasons why compiled Image Recognition scripts fail don't seem to apply here. I can force a dll error if I rename/delete the dll. I can force an image not found error if I rename/delete the image. Of course I can force no errors with Let>IGNOREERRORS=1, but you haven't done that and you're still not seeing any errors.

The only other reason I can think of is that numfound=0, which means it's not recognizing the image - because the image is somehow different? Or the image in your thumbnail folder is incorrect? But those reasons don't make much sense either. Is something getting in the way if the login button? The console?

I should add that my knowledge of Task Scheduler is very basic. It starts and ends with scheduling a compiled EXE.

EDIT : I mentioned this to Marcus and he suggested I double check that you're logged in and that the image actually visible.

Code: Select all

// COMPILE_OPTS|D:\compiled\AAAA\MDLP_4-8_Progress.exe||CONSOLE=1|INCLUDES=1| /NOSYSTRAY|RUNTIMES=1|BMPS=1
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1
VBSTART
Sub MinimizeAll
Set oShellApp = CreateObject("Shell.Application")
oShellApp.MinimizeAll
End Sub
VBEND
Wait>5
VBRun>MinimizeAll
//Let>CHROMEDRIVER_EXE=C:\SUSD_SQLApps\MacroScheduler\chromedriver.exe
Let>CHROMEDRIVER_EXE=C:\chromedriver.exe
Let>CHROMEDRIVER_OPTIONS=--start-maximized

ChromeStart>MDLP

Wait>3

ChromeNavigate>MDLP,url,https://www.mdlp.org/

Wait>3




//!!!!!!!!!RUNS TO THIS POINT JUST FINE!!!!!!!!!!!!!!!!!!!!

//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif
Wait>5
ChromeFindElements>MDLP,name,user_ID,elements
ChromeSetElementValue>MDLP,elements_2,[USERNAME]
ChromeFindElements>MDLP,name,user_pwd,pwd
ChromeSetElementValue>MDLP,pwd_2,[PASSWORD]
mdl>finished

exit

Yes, we have a Custom Scripting Service. Message me or go here

markir
Newbie
Posts: 6
Joined: Mon Oct 25, 2021 4:28 pm

Re: EXE Task Scheduler

Post by markir » Fri Feb 04, 2022 3:30 pm

Thanks for following up. All these tests were done while I was logged in and either manually running the scheduled task or scheduling it and watching it run. I am going to try and run it on a windows server. This is currently being run from a laptop running windows 10.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts