Windows 2000: Scripting solutions

When it comes to scripting, Windows 2000 offers plenty of choices. Scripting is, in simple terms, the use of an interpreted programming language to automate repetitive tasks, and even build small applications.


The CMD shell in Windows 2000 offers scriptability, similar to the old DOS BATch files, but with more features. As with DOS, a .bat extension tells CMD to treat the script as executable; however, just like NT and OS/2, Windows 2000 also treats files with the .cmd extension as executable scripts.

The native Windows 2000 shell scripting lets you do conditional looping, jumping and branching, and parameter substitution, and call other batch files as well. Global and local environment variables are also supported, plus output redirection with > < << >> and | [pipe] for further processing by other programs. The commands available to you include:call.pause.echo.rem.endlocal.setlocal.for.shift.goto.

% [variable].if.

These commands are well-documented: simply issue the /? switch after each (e.g., for /?) for an exhaustive list of options and sample code; combine this information with the output of the /? for other shell commands (e.g., NET USER) to write the pseudo-code for your script and, ultimately, the script itself.

Unlike UNIX, Windows shell scripts cannot access all areas of the system. There is no way, for example, to script the Disk Defragmenter to run automatically on certain volumes at given intervals, because the Microsoft Management Console (MMC) doesn't provide a command line interface.


A more powerful scripting solution for Windows 2000 is Microsoft's Windows Script, which, among other things, provides a way to script GUI apps - in fact, you could replace the text-only login scripts with VBS (Visual Basic Script) equivalents which provide a nice GUI for users. Windows Script is COM (Component Object Model) aware, giving you access to any system object you like, as long as they are registered with the operating system.

Windows Script requires the Windows Scripting Host (WSH) to be installed, and there have been several security issues with this in the past - some of the most widespread viruses have been VBS ones, using WSH to gain access to important system structures. The latest version (5.6 as of going to press) introduces a new security model that lets users verify scripts before running them. Developers can also sign scripts, to add another layer of authentication and protection against tampering, and administrators can establish policies that allow only certain users to run local and/or remote scripts. Download WSH plus documentation for it from, which also has code examples plus hints and tips for beginners.

WSH also contains Microsoft's JScript scripting engine, a script debugger, and several scripting components, on top of the Windows Script runtime. It allows you to create command-line apps (run them with cscript.exe), GUI ones (run with wscript.exe) and scripts that can be hosted through Active Server Pages on Internet Information Server. It's a comprehensive and complex scripting solution which takes time to master, so investing in some classes and books is a good idea.


If you're looking for a non-Microsoft scripting solution, PERL (, is hard to overlook. Created by Larry Wall, it's a mature and fully-featured interpreted language that has been in use on UNIX for years. There is an abundance of sample code and online tutorials to get you started, not to mention reusable PERL modules that simplify and speed up coding of applications significantly.

Furthermore, with a bit of planning (e.g., don't use WSH objects), your code will run on both Windows and UNIX.

PERL is extremely powerful for text string manipulation. Say you want to replace all instances of "change-me" with "to this" in a number of text files in a directory; if any file is changed, you want to save the original file with a .bak extension.

This PERL one-liner will do it for you:

perl -we "s/change-me/to this /gi" -p -i.bak *.txt

However, writing and maintaining large applications in PERL can be a chore, and it's not the easiest language in the world to learn.

The Win32 version of PERL is provided by ActiveState (www.activestate."com), which also develops Visual Studio plug-ins with a graphical debugger and source code revision control, for the language. ActiveState Perl is very well integrated with Windows and work is in progress to develop a .NET version as well.

Get the 12MB ActivePerl installer from http://downloads.activestate."com/ActivePerl/Windows/5.6/Active"Perl- (Microsoft Installer Package format).

Here are some good sites with sample code, as well as hints and tips for getting started with scripting:

Join the newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Juha Saarinen

PC World
Show Comments



Victorinox Werks Professional Executive 17 Laptop Case

Learn more >



Back To Business Guide

Click for more ›

Most Popular Reviews

Latest Articles


PCW Evaluation Team

Louise Coady

Brother MFC-L9570CDW Multifunction Printer

The printer was convenient, produced clear and vibrant images and was very easy to use

Edwina Hargreaves

WD My Cloud Home

I would recommend this device for families and small businesses who want one safe place to store all their important digital content and a way to easily share it with friends, family, business partners, or customers.

Walid Mikhael

Brother QL-820NWB Professional Label Printer

It’s easy to set up, it’s compact and quiet when printing and to top if off, the print quality is excellent. This is hands down the best printer I’ve used for printing labels.

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?