If you’ve been working in the computer world for a while then you’re probably pretty familiar with batch jobs. IT professionals around the world utilized them to run all sorts of automated computer processing jobs and personal tasks. In fact Paul recently covered how to write such a file.
The problem with batch jobs is that they were very limited. The command set was somewhat short and didn’t allow for very much functionality when it came to structured logic using if-then, for, next and while loops.
Later, Windows Scripting Host came along. The MS Windows Scripting Host is a multi-language script utility that Microsoft started installing as standard on all PCs from Windows 98 onward. By the second generation of the tool, it was renamed to Microsoft Script Host (MSH).
A Microsoft Scripting Host Tutorial
Here at MUO, we love computer automation. For example, Varun covered Sikuli (a tool to write automation scripts) and Guy showed you how to use AutoIt to automate tasks. The cool thing about MSH is that if you have any post-Win 98 PC, you can write a “batch” script in a variety of languages.
Available languages include JScript, VBA, and VBscript. It’s also possible to write scripts in Perl, Python, PHP, Ruby or even Basic if you have the right implementation with the right scripting engine.
Personally, I know Visual Basic well, so I usually opt for VBScript. The beauty here is that you don’t need any special programming software or compiler. Just open up Notepad and write your script, just like how you wrote your batch jobs.
Without installing anything, you can write scripts in VB. The simplest script is printing text to a pop-up window, like this:


To show you how cool this can be, I decided to write a script that would reach out to the NIST atomic clock to check the current time. If morning, it automatically opens my Thunderbird email client. If noon, it would open my browser to CNN.com. This conditional script gives you the ability to make your computer much more intelligent. If you run this script when your PC starts up, you can make it automatically launch whatever you like depending what time of day it is.

Here’s what the script does with just the code above implemented so far.


By the way, it’s a very good idea to have a reference of scripting commands handy when you write these scripts. If you’re into VBScript like me, a great resources is ss64.com, which lists all VBScript commands alphabetically on one page.



Some of the best sites to find pre-written scripts that you can use or customize include the following:
• Microsoft Script Center – Straight from microsoft, and includes categories like Office, desktop, databases and active directory
• Computer Performance – This UK site offers the best selection of VBScripts that I’ve seen online.
• Computer Education – You’ll find a small collection of scripts here, but they’re very useful and they all work.
• Lab Mice – An awesome collection of batch programming resources like an assortment of logon scripts.
Have you ever used the Windows Script Host? Do you have any cool tips or examples to share? Offer your insight and share your experiences in the comments section below.
(By) Ryan, an automation engineer on the East Coast (U.S.) who enjoys discussing the latest trends of online writing and freelancing. Visit his blog at FreeWritingCenter.com to read up on the latest online writing trends and freelance money-making opportunities. Sphere: Related Content
No hay comentarios:
Publicar un comentario