WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: mjwillyone on August 05, 2021, 01:56:47 PM

Title: Scheduled Winbatch Routines
Post by: mjwillyone on August 05, 2021, 01:56:47 PM
Just a quick question ...   Does Winbatch have a way to schedule the running of *.wbt files on a timed, daily basis?  I have searched the forum and I have read what some have attempted to do to get Winbatch routines running on Windows computers using the Windows Scheduler .. .but I would think it might be easier that then ...
Title: Re: Scheduled Winbatch Routines
Post by: td on August 06, 2021, 07:26:17 AM
It seems silly to reinvent the wheel and the Windows Task Scheduler is not that difficult to use. So the Task Scheduler is likely the best way to run any task on a regular basis on Windows. It is easy to use because there are multiple ways to schedule a task. An incomplete list of ways to use the Task Scheduler includes the  UI applet, the schtasks.exe command-line program, and the "Schedule.Service" COM Automation object. The latter can be used inside a WinBatch script.
Title: Re: Scheduled Winbatch Routines
Post by: kdmoyers on August 06, 2021, 08:05:49 AM
I've tried to do a better job than the Windows Task Scheduler and have failed miserably every time.  I just use it now.
Title: Re: Scheduled Winbatch Routines
Post by: mjwillyone on August 06, 2021, 08:49:35 AM
td, sorry to be such a problem.   There are 3 elements (see attachment) that can be used to set up the scheduler to run a .wbt file without adding any script to the Winbatch file ... I was just hoping someone who has used it before can give some insight.  Just putting path to the wbt file won't do it.

My goal is to automate no less than 50 tasks that our bookkeeper currently does ..  and using scheduler to take care to see them done outside typical office hours.  So .. this is pretty important to me.
Title: Re: Scheduled Winbatch Routines
Post by: jmburton2001 on August 07, 2021, 05:58:29 AM
Quote from: mjwillyone on August 06, 2021, 08:49:35 AMJust putting path to the wbt file won't do it.

On the machine you're trying to schedule the .wbt files on... Is Winbatch installed and are the .wbt files properly associated? If not, they won't run.

One, among many, ways around that is to compile them (as a Large EXE for Standalone PC's) and then schedule the resulting exe's.
Title: Re: Scheduled Winbatch Routines
Post by: cssyphus on August 07, 2021, 07:58:32 AM
Another option - and one I use quite a bit - is to create an app that just runs as long as the computer is on. Start the app via the Startup folder.

The entire app is inside a while loop that never ends. (e.g.  while 1 .... endwhile), and you can call various goSubs in succession. Each :Subroutine can check the time, and if the time is after your trigger time, run the procedure and then create a var such as _ranBackup = timeYmdHms() -- the beginning of the subroutine checks if isDefined(_ranBackup) and, if so, just Returns.

The final goSub in the while loop checks if it is midnight, and if so, drops the vars so all is ready for the next day.  Nice thing about using timeYmdHms() as the content of a var:

if timeDiffSecs(timeYmdHms(), _ranMidnightReset) > (60*60*2) then drop(_ranMidnightReset), and you are ready for the next EoD.
Title: Re: Scheduled Winbatch Routines
Post by: td on August 08, 2021, 09:09:31 AM
Quote from: mjwillyone on August 06, 2021, 08:49:35 AM
td, sorry to be such a problem.   There are 3 elements (see attachment) that can be used to set up the scheduler to run a .wbt file without adding any script to the Winbatch file ... I was just hoping someone who has used it before can give some insight.  Just putting path to the wbt file won't do it.

My goal is to automate no less than 50 tasks that our bookkeeper currently does ..  and using scheduler to take care to see them done outside typical office hours.  So .. this is pretty important to me.

You need to specify WinBatch.exe as the program to execute with your script as an argument to WinBatch.exe. Note that you should likely supply the complete path to the executable and script and that you may need to choose a different version of the WinBatch exe depending on your other settings. Look in the WinBatch system directory for the names of all the exes available. Here is a link with a description of the various WinBatch executables:
https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+~+Run~Scripts~on~Windows~Vista~and~Newer.txt (https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+~+Run~Scripts~on~Windows~Vista~and~Newer.txt)

One approach could be to start with WinBatch_if.exe and change to WinBatch.exe or one of the other exes if warranted.

Here is a link to an article about one more thing you also need to consider:
https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+Scheduled~Tasks.txt (https://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/nftechsupt.web+WinBatch/UAC+Scheduled~Tasks.txt)

It may seem a bit overwhelming because it requires learning something new but this is not that complicated. Give yourself some credit.
Title: Re: Scheduled Winbatch Routines
Post by: td on August 08, 2021, 09:12:54 AM
Quote from: cssyphus on August 07, 2021, 07:58:32 AM
Another option - and one I use quite a bit - is to create an app that just runs as long as the computer is on. Start the app via the Startup folder.

The entire app is inside a while loop that never ends. (e.g.  while 1 .... endwhile), and you can call various goSubs in succession. Each :Subroutine can check the time, and if the time is after your trigger time, run the procedure and then create a var such as _ranBackup = timeYmdHms() -- the beginning of the subroutine checks if isDefined(_ranBackup) and, if so, just Returns.

The final goSub in the while loop checks if it is midnight, and if so, drops the vars so all is ready for the next day.  Nice thing about using timeYmdHms() as the content of a var:

if timeDiffSecs(timeYmdHms(), _ranMidnightReset) > (60*60*2) then drop(_ranMidnightReset), and you are ready for the next EoD.

That approach will work as long as IT policy permits it and a user is logged on. There are several registry-based ways to execute scripts automagically, as well. The Task Scheduler is a safe bet but whatever works is obviously the best solution for you.

[edit] And yes, you do need to have WinBatch licensed and installed on the system that is running an uncompiled script. If not then you need to compile the script.
Title: Re: Scheduled Winbatch Routines
Post by: td on August 08, 2021, 04:50:52 PM
An easy way to see all the Startup programs on a Windows 10 system is to click Start and then type "System Information". Once the applet displays expand "Software Environment" and then click "Startup Programs." Depending on your systems configuration you will possibly have several "run" registry key locations and Windows shell start folder(s).
Title: Re: Scheduled Winbatch Routines
Post by: mjwillyone on August 26, 2021, 02:07:48 AM
Thank you very much!!
Title: Re: Scheduled Winbatch Routines
Post by: mjwillyone on September 13, 2021, 10:36:14 AM
Ok.  here is what worked with my Windows 8.1 Scheduler  running a wbt file (it took some time to figure out what info needed quotes, and what didn't:

Program/script:   "C:\Program Files (x86)\WinBatch\System\WinBatch_IF.EXE"

Add arguments: TimeNow.WBT

Start in:  C:\Users\myname\Desktop\

NOTE:  I had to remove all spaces in the WBT file name of this wouldn't work!!!    Leave it to Microsoft to design an automation tool that takes forever to set up!