Naming Scripts

Microsoft® Windows® 2000 Scripting Guide

If you are like most people, you consider the 8.3 naming convention (file names consisting of no more than 8 letters, followed by a three-letter file extension) to be a bygone relic of the distant past. Admittedly, there is probably no need to limit file names to the 8.3 naming convention; however, there are good reasons for keeping file names as short as possible and for not including spaces or special characters in those names. Although the name "Create an Exchange mailbox for a new user.vbs" clearly indicates the purpose of the script, long file names can create problems for system administrators who actually use the script. For example, to run a script named "NewMailbox.vbs" from the command line, you need only type the following:

newmailbox.vbs

By contrast, it takes more time to type a long file name such as the following:

"create an exchange mailbox for a new user.vbs "

Not only does this require additional typing, but using spaces in the name requires you to enclose the command in quotation marks. This can make it difficult for an administrator with limited command shell experience to run the script; he or she might not know that the file name must be enclosed in quotation marks. If the script requires arguments that must also be enclosed in quotation marks, the command-line string becomes even more complicated, and the chances of making an error are even greater.

Tip

  • Because long command-line strings are difficult to remember, and even more difficult to type in correctly, you should also limit command-line arguments to single letters. Typing a command such as sample.vbs /? is easier and faster than typing sample.vbs /help. Similarly, use standard command-line arguments such as sample.vbs /?. Do not invent for your own "standard," such as sample.vbs /more_info.

File or path names with spaces also make calling scripts and batch files from Windows Script Host (WSH) more difficult. As shown in the following code sample, starting a second script from WSH is easy when the path name does not contain spaces.

Const VbNormalFocus = 1
Set objShell = Wscript.CreateObject("Wscript.Shell")
intApplicationStarted = objShell.Run("C:\Scripts\CreateUsers.vbs", _
    vbNormalFocus, True)

This same call is more difficult when there is a space in the path name because the Run method requires you to enter the path exactly as you would from the command prompt. When entering commands from the command prompt, you must enclose path names that include spaces in double quotation marks as follows:

"c:\scripts\create users.vbs "

Because the Run method also requires double quotation marks around the path name, you must use three sets of double quotation marks to start the application. This makes the statement more difficult to write and more difficult to maintain:

Const VbNormalFocus = 1
Set objShell = Wscript.CreateObject("Wscript.Shell")
intApplicationStarted = objShell.Run("""C:\Scripts\Create Users.vbs""", _
    vbNormalFocus, True)

As you might expect, it is also a good idea to avoid using spaces in folder names and to keep scripts in top-level folders whenever possible. Typing C:\Scripts\CreateUsers.vbs is much faster and easier than typing "C:\Program Files\Administrative Tools\Domain Admins\Scripts\Active Directory\User Management\Create Users.vbs."