Chapter 01 - Hello World, Part IIIn Part I of this chapter, we learned how to create, load, and run a simple script. In this second Part, we will learn how to add a job (our HelloWorld.vbs) to our main scheduler.
1. Launch TaskGhost if it is not already running, and hit the
Stop button to make sure we’re not running any jobs.
2. Open the Schedule.vbs file in the TaskGhost\Scripts directory—not the Sample Scripts directory—in your favorite TEXT editor, I use notepad.exe. This is your main schedule and contains the statements to schedule and launch all your various jobs.
3. Locate the table of triggers, they start with “If TGCtrl.CheckTime (…”
Add a single line to this section that looks like this:
If TGCtrl.CheckTime (2, tc, "* * * * * * * *") = true Then TGCtrl.Run 0, "HelloWorld.vbs", vbNullString
The above statement should all appear on a single line within your script.
Now, before we try out our scheduled HelloWorld job, let’s make a quick check of our schedule to see if the job identifier we’re using (
2) is unique. That is, that it’s not being used by any other jobs.
The job identifier is shown here in bold:
If TGCtrl.CheckTime (
2, tc, "* * * * * * * *") = true Then TGCtrl.Run 0, "HelloWorld.vbs", vbNullString
If the job identifier is being used by another job, select another numeric value. It’s not really important what the value is, just that it’s unique.
1. Okay, save your Schedule.vbs.
2. Use the
Load button and navigate to the TaskGhost\Scripts directory.
3. Select the Schedule.vbs file (once selected, it will run.)
You should see a screen similar to this one: 
If all went according to plan, you should see “Hello World!” being printed once a second to the TaskGhost console.
Okay, now press the
Stop button.
You should see a screen similar to this one: 
In Part III of this first chapter we will discuss the How’s and Why’s of what we’ve seen so far.