Hey, Scripting Guy! 2009 Scripting Games Event 10 Details (Beginner and Advanced; 1,500-meter race)

2009 Summer Scripting Games

Beginner Event 10: The 1,500-meter race

In the 1,500-meter race, you will go for the gold by writing a script that counts down from three minutes.

Event Scenario

In a classic Rolling Stones song, the British band brags, "Time is on my side, yes it is." This is good advice for this event. Time is on your side. The IT pro often must be able to track time, quickly and easily. There are two kinds of time keeping: counting down and counting up. When you count up, you are trying to see how long an activity is taking. Examples are everywhere. The 1,500-meter race for one. The athletes go for the gold by running a set distance in the shortest amount of time. The stopwatch is used to determine the elapsed time. "How long did it take for the first athlete to cross the finish line?" IT pros use stopwatch technology in performance tuning. "How long does this workstation take to boot up? How long does it take for this web page to load?" We use the measurements to determine speed.

On the other hand, there is the type of time where we count down from a certain number. Athletes use this type of time keeping as well. "How many pushups can you perform in two minutes?" "How many pull-ups can you perform in one minute?" For these types of scenarios, a countdown timer is used. These are sometimes referred to as egg timers because of the famous three-minute hourglass that is used to govern the making of a hard-boiled egg. Countdown timers in sports and IT are used to measure strength. How many I/O operations is the computer capability of performing in one minute?

In this event, you must write a script that will count down from three minutes to zero seconds. When the three minutes have expired, display a message indicating that the given amount of time has elapsed.

Note:  There are so many add-ons you can develop for this script. You may want to write a script that includes the starting time and the ending time for the three minutes. You should add in the ability to change the amount of time the script will be timing. For example, allow a user to time five minutes or ten minutes, or 5 seconds for that matter. You may want to add in a progress indicator. In Windows PowerShell this is easily done, but in VBScript you could do essentially the same thing rather easily by running the script under CScript and printing text to the prompt.


Advanced Event 10: The 1,500-meter race

In the 1,500-meter race event, your script will need to be able to go the distance as you dynamically change the priority of a particular process every time the process is launched.

Event Scenario

Every process on a computer runs with some priority. Some processes run with low priority; others run with (wait for it) high priority. Developers are able to decide the priority a process should have when they write the code that creates the process in the first place. This is covered in the Windows Internals book from Microsoft Press. In general, developers do a good job with this; however, they do not always know the intricacies of your particular system. Even though there are utilities on the Internet that will allow you to permanently set a particular processes priority via Task Manager, those utilities are not always available in closed environments.

Your task is to write a script that will detect when a particular process, such as Notepad.exe starts. When the new process is detected, you must change its priority from normal to some other priority. To make the script really useful, you must be able to change both the name of the process being monitored and the priority to which the process will shift when the script is launched.

Note:  We did not specify that the script must use command-line arguments. You may want the script to read a text file containing the process name and new priority, a database, or an Office Excel spreadsheet. Or you might want to make a choice from a drop-down list mandatory. However you wish to write the script is up to you. Consider how you would use such a script on a day-to-day basis and choose accordingly.

Comments (1)

  1. Anonymous says:

    All the Scripting Games links in one location! Let the learning begin. (We will update this page every

Skip to main content