Custom COM for WSH

Alex Angelopoulos (aka at mvps dot org)

A surprising variety of obscure tasks can be performed by WSH with no assistance from custom components, especially when ADSI and WMI are added to the scripting arsenal.

However, there are still many times when it can be convenient to make use of custom components.  There may not be a solution to a problem readily available, or even if there is it may be extremely slow, not available on all operating systems, or too cumbersome for easy use.

I've created several small ActiveX components in the past to perform special-purpose tasks.  Most are my own work, although I have added a few components designed by other people and compiled by me.

A note on dependencies:

Unless otherwise stated, all of the DLLs below were written in VB6; consequently, your system needs the VB6 runtimes installed to use them.  Most systems deployed today have them (including Windows XP and .NET server).  If yours does not, you can find a link to the download in the following MSKB article:

Q192461 - FILE: VBRun60.exe Installs Visual Basic 6.0 Run-Time Files

You will need to reboot after installing the runtimes.


TsModes - [2002.10.13]

DLL which allows you to query and set user, logon, and flat temp directory modes for a Terminal Server from script.  This avoids use of direct shell spawning, file writes, and read-and-delete by use of local system pipes.

IdleTime - [2002.10.08]

COM wrapper around the GetLastInputInfo API; returns current system idle time in milliseconds.  Includes the DLL and a demo script.

Find Windows/Applications By Window Classname

This component will allow you to find a window or application by its private classname.  It was originally written as a helper application for converting a Win9x workstation into a Winstation for use with Terminal Services, so it also exposes Shutdown and ForceShutdown methods, and is bundled with a script for use with a Winstation config.

Convert to Bitmap

A small class allowing you to convert JPEG, icon, GIF, and WMF files to bitmaps from script.

Find FileOwner

Returns the owner of a file. Based on MSKB article Q218965.

Touch

Allows you to modify a file's datestamps

TsScript

Some basic functions for TS session and server scripting.

Uptime

Returns current system uptime

Wallpaper

Allows you to change and refresh the system wallpaper on-the-fly.

Clear Internet Cache and Cookies

This is a small component that will completely clear your Internet cache and cookies. NOTE: This means it WILL delete your cookies!

Recursive MkDir Function

They didn't include one in WSH, even though it is a plain, simple, short API call from C++.

sox

This is one of the earliest general-purpose API wrappers I wrote for use from script.  As such it is sloppy, potentially unstable, and may or may not work as billed.  It does include a variety of special classes for accessing miscellaneous API functions.  I don't recall it in other than vague detail, so the only documentation is what is exposed by the interfaces.