Windows Command Scripting

What is Command Scripting?

Command line scripting is simply a collection of command shell (or ‘DOS’) commands collected into a file which are executed sequentially.
In the world of Microsoft® Windows® (and DOS) we call this a batch file. It has the extension of either .BAT or .CMD, the latter being used only for Windows NT® or above.
*Note:In the world of UNIX/LINUX this is called shell scripting. Due to the nature of the UNIX operating system and it’s shells, shell scripting tends to be far more powerful than the Windows® equivalent. This is mostly due to historical differences but extended support and power have improved significantly since the introduction of Windows® NT®.

What can I do with Command Scripting?

Basically, you can do just about anything.
Generally, however, there are limitations in what the command shell can do, but many limitations can be overcome by using innovative methods. This can best be demonstrated in some of my more advanced example scripts, for example, the command shell does not provide a means to change the case of a word or string. Using a string manipulation utility like CHGSTR allows you to achieve this, even though this is not it’s intended function.
The truth of the matter is that the success of any script is simply dependent on having predictable input, i.e. input that always takes the same form, no matter what the content, for example, the time can be extracted using the %time% variable and is always in the format hh:mm:ss.ll, where hh=hours, mm=minutes, ss=seconds and ll=milliseconds.

To give you an idea, over the years I have used scripts to build functional user menus, enhanced logins in both Windows® and Netware® environments, asset management, server and service monitoring and reporting, database maintenance, data migration, automated system builds, hardware and software inventory etc. etc., the list just goes on. I will write a script wherever I feel it might be beneficial to either myself or someone else. Typically, a script will either provide something that is needed or it will save time. Either way, it will save money.

How do I get started?

Become familiar with the Windows® command line. Just open the Command Prompt from the Start Menu and start learning. Type ‘help’ for a list of commands. Type ‘help command‘ or ‘command /?’ for specific help on any command. If you would like a tutorial try the rest of my scripting pages, starting with The Basics.

Leave a Reply

Your email address will not be published. Required fields are marked *