Writing scripts for Windows isn't like writing batch scripts for MS-DOS; the scripting capabilities of the latest version of Windows (XP/2003) are far more powerful than the batch scripting language but also far more complex. Microsoft has an excellent site on TechNet, the Script Center, that has lots of tutorials, articles, and resources to help you learn how to write Windows scripts. But the actual process of writing scripts hasn't really changed from the way we used to write batch files for DOS--it's still basically all about opening up Notepad and doing a bunch of typing, carefully. Isn't there an easier way to write scripts?
Well, the first thing you can do is see if someone has already written a script that can do what you're looking for. The Script Center Script Repository has just that--hundreds of sample scripts you can use as is or customize as needed. Or you can Google and see what other sites have collections of Windows scripts, because there are many of them around. One of my favorites is the VB Scripting Downloads section of myITforum.com, a site run by Rod Trent, a friend of mine. Most of the scripts here are for use in SMS/MOM environments, but you can find lots of other useful stuff too. If you know of other good Windows script repositories, let me know in the feedback section below and I'll share it with others.
If you can't find an existing script that can do what you want, try posting to one of the scripting newsgroups on msnews.microsoft.com. These include:
You can access these groups either in a newsreader using news://msnews.microsoft.com or using a web-based interface on the Newsgroups page of the Microsoft Communities web site. Whichever method you choose, post your scripting need in the right group and you're likely to find someone who will write it for you just for the sheer exhilaration. (Some people get exhilarated by the strangest things; I like blue skies and red sunsets myself.) Or go to one of the many other popular online IT communities around: the myITforum.com discussion forums, Experts Exchange, and others. Again, I'd be interested in hearing which online forums you find most useful for getting help in writing scripts.
If you lean toward the power end of things, try searching the Microsoft Download Center for tools to help you write scripts. Goodies you'll find there include HTA Helpomatic, a tool that can be used to create HTML Applications (HTAs) for your scripts so they can have a graphical user interface that includes check boxes, radio buttons, list boxes, and other controls. You can use Helpomatic to build a front end for your script to make it easier to use, and you can even run different scripts by clicking on different buttons on a web page. Then there's Scriptomatic 2.0, a newly revised tool that helps you easily write Windows Management Instrumentation (WMI) scripts even if you're a novice at understanding how WMI works. WMI is a powerful interface in Windows that lets you view and change configuration settings for almost any component of a Windows system or network. You can also find the TechNet Script Center sample scripts on the Download Center in one easy-to-download package. This is really convenient and saves time browsing through pages of scripts in the Script Center and copying scripts one at a time and saving them. There's even a Do-It-Yourself Script Center Kit that lets you build your own version of the TechNet Script Center, either as a web site or a Windows Help (.chm) file.
Finally, consider all the books out there on Windows scripting. There are a number of good ones, especially for learning how to script, but if you're just looking for some quick and dirty scripts to use and maybe customize a bit, pick up a copy of Windows Server Hacks (there he is, shamelessly promoting his book again!), which contains dozens and dozens of scripts developed by the myITforum.com community and other "geeks like us."
Mitch Tulloch is the author of Windows 2000 Administration in a Nutshell, Windows Server 2003 in a Nutshell, and Windows Server Hacks.
Return to the Windows DevCenter.
Copyright © 2009 O'Reilly Media, Inc.