Windows IT Pro is the leading independent community for IT professionals deploying Microsoft Windows server and client applications and technologies.
  
  
  Advanced Search 


November 1997

Automating NT Administration with Scripts


RSS
Subscribe to Windows IT Pro | See More Systems Administration Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!
SideBar    Scripting Languages for NT

The Perl Script
Let's rewrite the batch file in Listing 1 to demonstrate Perl's capabilities. First, you need to install Perl for Win32 on your workstation. Download pw32i310.exe from the ActiveState Tool Web site (http://www.activestate.com). Place this self-extracting file into the Perl installation directory (e.g., c:\Perl), and invoke pw32i310.exe to fire up the installation.

At A in Listing 2, page 184, the script declares three variables: $RegKey, $RegValue, and @Servers. $RegKey holds the Registry key, $RegValue holds the Registry value, and @Servers is an array that holds the list of servers.

The script then prompts the user for the key and value, and stores the user's input in $RegKey and $RegValue. The chop function is a Perl function that removes the last character from a string. In Listing 1, chop removes the new line character that results from the user pressing the Enter key after typing the Registry key and value.

At B in Listing 2, the script opens the file that contains the list of servers and reads the list into the @Servers array. In this example, the script expects the servers.txt input file to be an ASCII file with one server name per line.

Next, the script opens the getregval.txt output file and writes some header information into it. At C in Listing 2, page 185, the script loops through the @Servers array, calling the Perl for Win32 Registry functions to connect to the Registry, retrieve the Registry value, and write the returned value to the output file. Screen 2, page 183, displays the executing script and the contents of the output file.

Unlike with the command-line script, you don't have to edit the Perl script to support additional servers. You simply add them to the servers.txt input file. In this example, I also enhanced the output file format to make it more readable.

The Final Script
Listing 3, page 185, presents the Final version of the Registry script. Before you can run the script, you must install Final for NT Server on your workstation. A Final source file has an .fc extension, which you must compile to an .fbi file before you execute it. I compiled this script in the Final IDE, and then passed it to the Final runtime using the command line

c:\>finalrun getregval.fbi

Final can also generate standalone executable files, but you must buy this feature as an add-on product option.

The Final script differs from the Perl script primarily in that Final offers a GUI. Perl for Win32 has no GUI support today, although ActiveState Tool is working on a GUI. However, you can use an HTML form and a browser as an alternative interface for the Perl script. Screen 3, page 183, shows the opening dialog box in the Final script.

Scripting Power
To get an idea of just how powerful some of these scripting languages are, browse the function libraries that come with the software. I'm sure you'll find that you can offload to a script some of the day-to-day tasks listed in Figure 1.

To obtain demonstration copies of the scripting tools mentioned in the sidebar "Scripting Languages for NT," browse the companies' Web sites. Most sites include example programs to get you up to speed quickly. FastLane's Final includes an example script for each of the NT functions it supports.

Scripting will continue to evolve. You must look no further than Microsoft's recent scripting initiatives to see that scripts can play an important role in enterprise systems management. So try your hand at automating your work with scripts--you might surprise yourself!

You can download the listings in this article from the magazine's Web site, http://www.winntmag.com.

Figure 1: Example Tasks for Scripting
Managing access control list (ACL)
Configuring applications
Auditing systems and reporting audits
Managing files and shares
Managing OS patches and upgrades
Managing the registry
Automating repetitive tasks
Configuring servers
Controlling and configuring services
Tracking system availability
Adding, changing, and deleting users

End of Article

   Previous  1  [2]  Next  


Reader Comments

You must be a registered user or online subscriber to comment on this article. Please log on before posting a comment. Are you a new visitor? Register now




Top Viewed ArticlesView all articles
Command Prompt Tricks

One reader shares his tip for setting up the command prompt to reflect a remote path. ...

WinInfo Short Takes: Week of November 23, 2009

An often irreverent look at some of the week's other news, including some post-PDC some soul searching, a Google Chrome OS announcement and a Microsoft response, Windows 7 off to a supposedly strong start, the Jonas Brothers and Xbox 360, and so much more ...

2009 Windows IT Pro Editors' Best and Community Choice Awards

Picking a favorite product from an impressive crowd of competitive offerings is never an easy task, and such was the case with our Editors' Best and Community Choice awards this year. ...


Related Articles Modify the Registry with Perl

Related Events Deep Dive into Windows Server 2008 R2 presented by John Savill

Configuration Manager SP1 and R2 Overview

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Introducing Left-Brain.com, the online IT bookstore
Looking for books, CDs, toolkits, eBooks? Prime your mind at Left-Brain.com

Discover Windows IT Pro eLearning Series!
Clear & detailed technical information and helpful how-to's, all in our trademark no-nonsense format


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro DevProConnections IT Job Hound
Left-Brain.com Technology Resource Directory asp.netPRO ITTV Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 © 2009 Penton Media, Inc. Terms of Use | Privacy Statement