Skip navigation

Scripting Central--40 Lashes--November 4, 2005

1. Perspectives

  • 40 Lashes
  • 2. Scripter's Toolkit

  • The Write Stuff
  • 3. This & That

  • The "My Favorite Function" Contest Continues
  • 4. Scripting Scuttlebutt

  • Script Is a Success With a Little Help From Some Friends
  • 5. Script Watch

  • RunProgram.vbs Offers Remote Possibilities
  • Populate.vbs Lets You Size Up Exchange Mailboxes the Easy Way
  • 6. New & Improved

  • Buy Yourself an Early Christmas Present

  • 1. Perspectives
    by Karen Bemowski, [email protected]

    40 Lashes
    In case you haven't noticed, it's November already. If you read last month's "Perspectives" column in Scripting Central, you might be wondering why Code Central--Windows IT Pro's new searchable storehouse of scripts and programs ( that was supposed to debut at the end of October--is still displaying the "Code Central is coming soon!" message instead of displaying lots of code.

    With three dogs running around my house, I could say that they ate all the paperwork when I was working on it late one night. However, they're really good dogs, so I hate to give them a bad rap. Or I could say that our computer system had a virus, so it called in sick a lot. But the truth is that this project has turned out to be a lot larger than anticipated.

    Code Central will feature an area in which visitors can post scripts they've written and would like to share with fellow scripters. This part of Code Central is ready and waiting for scripts. Code Central will also feature code that has been published in the various Windows IT Pro print publications (i.e., Windows Scripting Solutions, Windows IT Pro, SQL Server Magazine, Exchange & Outlook Administrator, and Windows IT Security). This code is the problem child because many of these publications have been around for years. With Windows IT Pro celebrating its 10th anniversary this year and Windows Scripting Solutions turning 8 next year, there are numerous scripts to migrate into Code Central.

    Rather than doing a half-baked job, we decided to postpone the launching of Code Central. When it finally does open its doors, Code Central will provide a searchable repository chock full of scripts. You'll be able to search for scripts by scripting language (e.g., VBScript, Perl), scripting technology (e.g., Windows Management Instrumentation--WMI), the name of a particular scripter, or the type of task you want to automate. You can even search the scripts themselves for keywords. We hope the wait will be worth it.

    2. Scripter's Toolkit

    ' Editor's note: Ze'ev Ionis is the first winner of the "My Favorite Function"
    ' contest. His VBScript function named WriteIt writes to a text file whatever
    ' text you send it. For information about how to enter your favorite VBScript
    ' or JScript function in this contest, see the "This and That" section.

    The Write Stuff
    WriteIt is a very simple function that I use all the time to output error messages to a log file. I usually accumulate the errors into a string, which I then output to a log file at the end of the script. When I want to write error messages more frequently, I use this function to append them to a file.

    The code for the WriteIt function is

       Function WriteIt(aStr,strOP_F)
          Const ForReading = 1, ForWriting = 2, ForAppending = 8
          Dim fso, f
          Set fso = CreateObject("Scripting.FileSystemObject")
          Set f = fso.OpenTextFile(strOP_F, ForAppending, True)
          f.WriteLine aStr
          Set f = Nothing
          Set fso = Nothing
       End Function 

    In this function, the aStr variable contains the string of accumulated errors and the strOP_F variable contains the log file's pathname. At the end of the function, I set the objects I used to Nothing. Although it's not necessary to set objects to Nothing in VBScript, I do it as a matter of good practice, as you usually have to do in other languages.

    To call the WriteIt function in a script, you use the syntax

       WriteIt Text, LogPath 

    where Text is the text you want to write and LogPath is the pathname of the file in which you want to write that text. These two mandatory arguments can be variables (e.g., aStr and strop_F) or strings (e.g., "Hello World" and "C:\Test.txt").


    3. This & That

    The "My Favorite Function" Contest Continues
    Have you written a VBScript or JScript function that you constantly use in your scripts? Does this function require little or no modification each time you use it, so all you basically have to do is call it into action? If so, submit your VBScript or JScript function to Scripting Central's "My Favorite Function" contest.

    Three winners will be chosen (one a month for 3 months), each of which will receive $100 and get his or her function published in Scripting Central and in Windows Scripting Solutions' "Snippets to Go" column. In addition, the three winners will be put into a drawing for another $100. We have one winner so far (see the "Scripter's Toolkit" section).

    To enter the contest, send a description of what your VBScript or JScript function does and how to use it in a script (e.g., how to call it). In addition, include the function code. You can email your entry to [email protected]. Please include your full name and telephone number. Look for the second month's winner in the December 2 edition of Scripting Central.

    4. Scripting Scuttlebutt
    What's on your mind? Let us know at [email protected]

    Script Is a Success With a Little Help From Some Friends
    I recently submitted a request for scripting help to Windows Scripting Solutions. I was looking for suggestions on how to create a script that would remove the old pinned items from a Start menu, install Microsoft Office 2003, then pin new Office 2003 Word and Excel shortcuts to the Start menu.

    In "Rem: Updating Pinned Start Menu Shortcuts" (November 2005,, Bill Stewart answered my call for help. I'm now in the process of taking his suggestions and preparing an upgrade package from Office 2002 to Office 2003.

    I was able to remove the old pinned version of the shortcut using some help I found from Doctor Scripto. Even though I had renamed the pinned shortcut to "Word 2003," I could unpin it with the original shortcut name (winword.exe). Bill's suggestion that I needed to work with the Office 2003 Custom Installation Wizard (CIW) was certainly useful. Then it was a simple matter of getting the shortcut pinned. I had been trying to invoke the Rename verb and it just was not happening. Thank you for all your help!

    5. Script Watch

    RunProgram.vbs Offers Remote Possibilities
    If you often have to execute programs on remote machines but are tired of using the available tools (e.g., Task Scheduler) because they have certain drawbacks, you'll probably be interested in RunProgram.vbs. This script uses Windows Management Instrumentation (WMI) to run programs either locally or remotely. This script can also wait for the program to end and display the program's run time. To get the rundown on RunProgram.vbs, check out Bill Stewart's article "Another Way to Run Programs" in the December issue of Windows Scripting Solutions.

    Populate.vbs Lets You Size Up Exchange Mailboxes the Easy Way
    Manually obtaining the size of every mailbox on a given Microsoft Exchange Server 2003 server is tedious. You have to launch Exchange System Manager (ESM), drill down to the mailbox store level, and export the mailbox list for every mailbox store. If you have more than one mailbox store on your Exchange 2003 server, you have to combine the mailbox lists in Microsoft Excel to get a complete list of mailboxes and their sizes. If you must do all this work just for one Exchange 2003 server in your Administrative Group, imagine how tedious this manual process would be if you have multiple Exchange servers. A much easier solution is to use the Populate.vbs script to automatically gather the data and place it in a Microsoft Access table. You can then use Access to run queries and print reports. Learn more about this script in the Reader to Reader article "Size Up Mailboxes the Easy Way" in the December issue of Exchange & Outlook Administrator.

    6. New and Improved

    Buy Yourself an Early Christmas Present
    It's doubtful that any of your family members will want scripting books in their Christmas stockings, but in case some books are on your Christmas wish list, listen up. Microsoft is offering a special deal in conjunction with Quantum Books. Quantum typically discounts Microsoft Press books at 35% off list price. For a limited time, Microsoft is offering an additional 5% discount, bringing the total discount to 40% off list price. Go to the Microsoft Script Center ( and click the Get 40% Off on Selected Microsoft Press Books link. After you select the books you want, enter the coupon code SCRIPT40 during checkout. The Script Center doesn't say when this promotion will end, so go there soon if you're interested.

    Contact Us

  • About Scripting Central -- [email protected]
  • About product news -- [email protected]
  • About your subscription -- [email protected]
  • This email newsletter is brought to you by Windows IT Pro, the leading publication for IT professionals deploying Windows and related technologies. Subscribe today!

    View the Windows IT Pro Privacy Policy.

    Windows IT Pro is a division of Penton Media, Inc. 221 East 29th Street, Loveland, CO 80538, Attention: Customer Service Department

    Copyright 2005, Penton Media, Inc. All Rights Reserved.

    TAGS: Windows 7/8
    Hide comments


    • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

    Plain text

    • No HTML tags allowed.
    • Web page addresses and e-mail addresses turn into links automatically.
    • Lines and paragraphs break automatically.