Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


February 1998

Windows Scripting Host in Action


RSS
Subscribe to Windows IT Pro | See More Task Automation Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here
Download the Code Here
Download the Code Here
Download the Code Here
Download the Code Here
Download the Code Here
Download the Code Here

 See corrections to this article

A hands-on guide to using WSH

Windows Scripting Host (WSH) is a new Microsoft technology that is sure to become extremely popular because of its versatility. WSH lets Windows NT host any Microsoft ActiveX scripting language, including Visual Basic Script (VBScript) and JScript (Microsoft's implementation of the ECMAScript scripting language, formerly known as JavaScript). WSH also lets NT host third-party ActiveX scripting languages, such as ActiveState Tool's PerlScript (http://www.activestate.com).

WSH is a general-purpose, scripting-enabling tool. With the base WSH object model and a scripting language, you can create scripts that automate common setup, configuration, and administrative tasks, including:

  • Reading and writing variables in your directory services
  • Creating shortcuts for users on their desktop
  • Accessing special folders, such as Desktop, Start Menu, Favorites, and My Documents
  • Mapping network shares
  • Mapping and setting default printers
  • Reading, writing, and deleting Registry keys
  • Launching programs

The base WSH object model consists of five types of objects: WScript, WshShell, WshNetwork, WshShortcut, and WshUrlShortcut. As Table 1, page 124, shows, each object type has certain properties and methods that define it. (If you are unfamiliar with the component object model—COM—concept and ActiveX objects, see http://www.microsoft.com/activex.)

Two of the WScript object's methods—GetObject and CreateObject—work with any ActiveX object servers (including NT 5.0's ActiveX Directory Objects) registered on the local system. Thus, you can use WSH to access other object servers, such as Active Directory Services Interface (ADSI), Internet Explorer (IE), and Microsoft Office. With WSH and these object servers, you can set passwords, add users and organization units, initialize a browser, and manipulate and print documents.

Microsoft will integrate WSH into Windows 95 updates, NT 5.0, and the NT Option Pack. You can download WSH from Microsoft's Web site (http://www.microsoft.com/management/wsh.htm) for use with Win95 and NT 4.0.

The WSH package is surprisingly small, consisting of two separate scripting hosts, three support DLLs, six sample scripts, and a Help file. The two scripting hosts—command shell (cscript.exe) and Windows shell (wscript.exe)—let you run scripts from a command line and from the Windows environment, respectively. The command-shell host is particularly useful when you combine it with traditional command-line options, such as piping the output to a text file or other device. The Windows-shell host uses message boxes to display output information (unless you use an additional ActiveX component to handle the file I/O). The following simple examples show how you can use these two scripting hosts.

   Previous  [1]  2  Next 


Corrections to this Article:

  • In "Windows Scripting Host in Action," the ADSI namespaces associated with NetWare 3 and NetWare 4 in Table 2 were incorrect. The NetWare entry should be NWCOMPAT://ServerName/Object/subobject/.... The NetWare 4 entry sould be NDS://TreeName/0=NAME/subobj=name/....
Top Viewed ArticlesView all articles
CES 2009: Ballmer Announces Windows 7, Windows Live, Live Search Milestones

During his first-ever Consumer Electronics Show (CES) 2009 keynote address last night in Las Vegas, Microsoft CEO Steve Ballmer announced the pending public availability of a feature-complete Windows 7, the final version of Windows Live Essentials, and ...

Command Prompt Tricks

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

Where is Microsoft NetMeeting in Windows XP?

...


Task Automation Whitepapers Essential Guide to E-discovery and Recovery for Microsoft Exchange

Continuous Data Protection and Recovery for Microsoft Exchange

Protecting (You and) Your Data with Exchange Server 2007

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Task Automation eBooks Spam Fighting and Email Security for the 21st Century

A Guide to Windows Certification and Public Keys

Keeping Your Business Safe from Attack: Patch Management

Related Task Automation Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


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 Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing