Classic Windows Scripting

ancient script

Before .NET and PowerShell were dreamt of, VBScript and COM objects were the most powerful scripting tools available in a vanilla Windows install. Using Microsoft’s default facilities is worthwhile because it obviates the need to deploy additional software and cope with that software’s life cycle and incompatibilities. For instance, a script written for Windows 2000 is likely to continue working in Windows Server 2008 x64 Edition. I use PowerShell/.NET for Windows scripting now, but I still regularly use VBScripts which are several years old. Here are several of these simple scripts.

Backgrounder

First, a backgrounder — VBScript has been installed by default since Windows ’98. The core language is limited, and it relies on objects to perform any actual work. Even file I/O or regular expressions require object creation. Several class libraries exist for more involved tasks, such as e-mail (CDO), XML (Msxml2), and Windows Management (WMI).

Two of the larger class libraries are offered by Windows Management Instrumentation (WMI) and Active Directory Services Integration (ADSI). WMI provides a consistent interface to Windows’ hardware and software configuration, while ADSI manipulates accounts, computers, and other objects in Active Directory. Combined, these facilities can systematically perform the bulk of system administration tasks.

This zip file contains the following VBScripts to perform simple administrative tasks. They are in the Windows Scripting File (WSF) format, which is an XML format that encapsulates scripts in XML while adding support for type libraries and limited self-documentation and help facilities. The WMI and ADSI scripts can run locally or on a remote machine.

[Zip Icon]
Download WSF Collection

The ZIP file includes the following scripts:

Windows Management Instrumentation (WMI)

adapt.wsf
View or change network configuration, including IP address and
DNS/WINS servers. Operates locally or remotely. Note that no changes
take place without the “/set” option.
rdp.wsf
Display, enable, or disable Remote Desktop on a Windows XP computer. Unlike
the registry edit, this script can remotely enable RDP without a reboot.
specs.wsf
Display basic tech specs of the passed computer / domain
who.wsf
Display who is logged in to Windows’ console.

Active Directory Services Interface (ADSI)

addtoadmin.wsf
Add specified user (/user:userid) to the local administrators group of the
specified computer(/computer:hostname).
openfiles.wsf
List files opened through Windows file sharing.
user2sid.wsf
Print the decimal style SID of an user.

Other COM Objects

msxml.wsf
Basic XML manipulation: validation, XPath filtering, and XML style sheet
transformations.
wmail.wsf
Generate a MIME mail message and send using raw SMTP or place in IIS
pickup directory.
Be Sociable, Share!

Tags: , ,

4 Responses to “Classic Windows Scripting”

  1. JonnyRo says:

    Awesome blog nathan. Right out the gate with some useful tools for your IT compatriots.

  2. Teddy Lim says:

    I get a 404 error when I click on the link. The file can’t be downloaded. This is disappointing.

  3. nathan says:

    Thank you for bringing this to my attention, Teddy; I corrected the URL.

  4. Find local roofing contractors

    Classic Windows Scripting « Nathan's Blog

Leave a Reply

Are you human? Answer this: *