VBScript Samples and Components
If you don't know about VBScript
VBScript (VBS) is a Windows scripting language: programming code that can be written as a text file
and "executed" like an EXE file. Script is run by an interpreter -- a program such as Internet Explorer
or the Windows Script Host -- that carries out the instructions given in script code.
The uses of VBS vary depending upon what the interpreter is.
VBS can be used in several different ways. It originated as a webpage
scripting language for Internet Explorer. When Netscape came out with javascript
for their Navigator browser, Microsoft followed suit by coming out with their own
VBScript. That version of VBS was only for IE Document Object Model scripting (DHTML in webpages).
It never caught on for webpage scripting because Netscape never supported it.
But Microsoft ended up using VBS in the Windows Script Host (WSH), a "next generation"
replacement for DOS batch files that has been part of Windows since Windows 98.
The WSH version of VBS added support for COM objects with the CreateObject
method. COM (component object model) is a big topic. COM and ActiveX basically refer to the same thing.
In brief, it is a system for providing programmable objects. COM is a major aspect of Windows
software in general, and of Windows itself. As a COM-compatible tool, VBScript can use
COM objects (provided by COM DLL, EXE and OCX files). For example, the scripting runtime library (scrrun.dll),
installed on Windows by default, provides VBS with the ability to read and write files through
the FileSystemObject object. Script
can also be used to "automate" COM-compatible software such as IE, MS Office programs,
Windows Installer, WMI, SAPI text-to-speech functionality, Windows Media Player, etc.
So in a sense, VBScript is comprised of the VBS language itself plus all
available COM objects on a given PC.
The many uses of VBS
The common uses for VBS include the following:
Windows scripting - handle files, settings, Registry, etc.
HTAs - create script-powered software that runs in an IE window using DHTML.
WMI - Windows Management Instrumentation. WMI is a script-accessible
system used mainly by network administrators to manage multiple PCs on a network.
Some of the WMI functionality can be useful to non-admins.
ASP - For webmasters using Windows servers, VBS can be used in ASP pages.
About The JSWare Code and Components
The code and components here are mainly in the 1st and 2nd category --
various utilities, classes and HTA programs written to do useful things, for anyone using
Windows. The components have been designed to extend the abilities of VBS. The HTA
programs include an MSI file unpacker, an MSI file editor, utilities to control XP services and fix XP
folder view, etc. An HTA (a webpage with no security limitations running in IE) can
be used to create fullscale software. The only notable limitations are that script
is relatively slow and webpage software usually looks a bit less polished than compiled software.
But HTAs have the advantage of being relatively easy to create, edit and maintain.
Most of the code here will be difficult for beginners. This is not
a tutorial site but rather a resource for scripters.
A note about WMI:
WMI (Windows Management Instrumentation), also known as WBEM, is a system that comes
pre-installed on WinME/2000/XP/Vista/7. It provides a number of functions to script that are especially of interest to
network administrators, such as reading logs and managing NT services on remote computers. For some operations
WMI can make the job much easier than the equivalent in VBS. On the other hand, WMI requires learning a new,
very complex system with an entirely different syntax from standard VBScript. And for systems that do not need
WMI (and may not have it installed) WMI could represent an unnecessary, additional security risk. (WMI is not
known to have specific security problems, but neither did DCOM, ActiveX, or HTA before problems
were discovered.)
Functions that might be performed with WMI
can generally be performed with the scripts and/or components available here. In some cases
script may even provide more thorough methods. For example, the WMI Installed Applications
classes are merely wrappers for Windows Installer, which can be accessed directly through the
WindowsInstaller.Installer object, as demonstrated in the Enumerate Installed Software scripts.
But WMI is used in a few of the scripts here: The WMI Registry class wraps the somewhat awkward
WMI Registry functions in a more usable wrapper. Also,
the XPFix utility uses WMI
to manage NT services.
VBScript Programming Information
Software
WEB-ED Webpage and Scripting Editor 5
(Version 5.79.620 released: June 20, 2009)
WEB-ED Webpage and Scripting Editor is a code editor mainly for
VBScript, HTML, DHTML, ASP, CSS, PHP, javascript.
There are extra, specialized functions
for HTML, VBS and CSS. VBScript colorcoding and debugging
also work in HTML files (within SCRIPT or ASP tags).
VBS functions include:
Colorcoding of keywords, variables and comments.
Code auto-completion popup for object methods and properties.
Function parameters popup - shows sub and function parameters as you type for
object methods, VBS methods, declared subs and functions - even when in external files.
Object browser to research available objects.
Configurable context help display for VBS methods.
Auto-case adjustment of variables and keywords.
Optional color printing of code.
Snippet library for code storage.
"Jump to last column" on carriage return for easier code indenting.
Format debugging.
Run scripts from the editor (and run in MS debugger if installed).
Help file includes introduction to VBScript for beginners.
All webpages and scripts on this website were written in the WEB-ED Editor.
(WEB-ED Editor version 5.79.620 is a minor update and major bugfix release of v. 5.79.
There were a number of minor bugs that got into v. 5.79 due to extensive restructuring. Those issues have
now been fixed. See the WEB-ED page for details.)
VBS Reference and Scripting downloads from Microsoft:
The latest version of the WSH is v. 5.6. There have been no updates
to VBScript or the Scripting Runtime library since version 5.1, but v. 5.6 does
include updates to the scripting host (wscript.exe).
The changes, which seem to be mainly intended for system
administrators, include new functions for remote script running and the ability
to sign scripts for security.
Microsoft seems to often reorganize their website
without providing forwarding links to new URLs. The two links below were
valid as of Septmeber 2003. If they don't work you might try doing a search
for Windows Script Host at Google.
Download page for VBS and WSH documentation:
WSH 5.6 CHM help files
Page with links to download of docs, WSH install files, tools, etc.:
Various WSH downloads
Scripts
|
Components
Information
|
(Note: Please use a browser for download. This website blocks "download helper" software.
See here for further explanation.)
|
Looking for something specific? Try the
Topic and Function Index Page
WinXP SP2 note:
If you are using WinXP with Service Pack 2 you may have trouble
using some of the webpage-based samples here. If so, see this page for explanation and solutions.
|
VBScripts
Sampler Pack - samplevbs.zip
This is a zip file containing a dozen VBScripts,
ranging from simple message boxes to multi-
function scripts that can write to the registry,
create textfiles, run programs, make shortcuts, etc.
Download samplevbs.zip (13 KB)
Text Ops - textvbs.zip
These are scripts to demonstrate the use of the Textstream object.
There are 4 scripts included:
Find how many times a given word or phrase occurs in a text file.
Replace instances of given text in a file.
Process an HTML file, yielding a text file version with all tags removed.
A very basic Textstream class block.
Download textvbs.zip (6 KB)
Back to Index
Files and Folders - filfol.zip
This pack has several scripts that deal with file and folder functions.
It contains samples of many of the FileSystemObject functions:
Change attributes of a file.
Remove all attributes, going down 4 folder levels.
(good for removing Read Only when files are copied from CDR)
2 scripts dealing with DateCreated and LastModified properties.
Examples of working with Drive, Folder and File objects.
Get special folder paths.
Download filfol.zip (8 KB)
Back to Index
WScript.Shell - wshell.zip
This zip pack includes 8 scripts dealing with WScript.Shell:
A demonstration of the many functions the Run command can perform.
Getting the paths to Shell "special folders" (Win, System, Startup, etc)
A script that uses 4 different methods to get 17 common folder paths.
A demo of Sendkeys that opens Notepad, writes text and saves the file.
Drag and Drop shortcut-making script.
Simple demo of Popup message function.
A script to manage multiple address books in Outlook Express.
Change the title bar text on OE4.
(Last 2 use RegRead and RegWrite.)
Download wshell.zip (8 KB)
Back to Index
Start Page Maker - spmaker.zip
The Start Page Maker is a VBScript that will automate
the making of a Start Page for Internet Explorer.
It's a 'wizard' that uses message boxes, a BrowseforFolder class and
a color picker class to walk through the creation of a 3-panel Start Page
(or Homepage) with links. The script will also install the new Start Page
as the IE default.
A second included script can be used to quickly add new links to
the custom Start Page while browsing.
Download spmaker.zip (12 KB)
Back to Index
IE-based Progress Bar - iebar.zip
This is a progress bar written as an inline class, or "class block".
The class can be pasted into any script to provide a progress bar derived from an IE window.
There are 2 nicer progress bars available in the component section below, but if you
don't want to use extra components the IE progress bar can serve fairly well.
The download includes 3 script demos and also demonstrates
using properties in classes. Once the class has been pasted at the end of your
script, the progress bar is created as an object and has several properties that can be
set, including icon, caption, back color, number of progress units, etc.
Download iebar.zip (16 KB)
Note: This script may be incompatible with IE7. See below.
Back to Index
Class Demo - ClassExtExe.zip
This pack includes a VBScript class with explanation and demo scripts. This is a class written
as an external file. The script also demonstrates drag-and-drop script functionality.
The ClsExtExe class includes 2 Registry functions:
1) Give it a file extension and it will return the full path of the default
program for opening that filetype.
2) Give it the name of a registered executable and it will find the full EXE path.
Download ClassExtExe.zip (5 KB)
Back to Index
Get-Let-Class Block - getlet.zip
This set of scripts demonstrates a class block. That is, a class
included into a VBScript that is used as though it were an external object. This class encapsulates text file
operations and shows the use of Get, Let and Err.Raise.
One of the demo. scripts is a Search-and-Replace utility that
uses the class to replace text when a file or folder is dropped on it.
Download getlet.zip (7 KB)
Back to Index
Desktop Pack - deskpack.zip
This is a pack of handy Drag-and-Drop scripts that can be left
on the Desktop. Some of these functions have been included in
other scripts. They're all together here with Drag-and-Drop functionality.
Change file attributes - drop a file on it to change any attributes.
Remove all attributes - drop any folder on it to remove file attributes
(such as Read-Only) down to the 4th folder level.
Character - Ascii translator (not Drag-and-Drop).
RegSvr script - drop a file on it to register or unregister a system file.
Tab remover - Ever copy and paste webpage text, then notice the
pasted text has wide tabs? This will remove them.
Internet Explorer homepage setting script.
URL converter - converts deliberately obscured URLs to readable.
EXE2CAB - converts a self-executing CAB file (EXE) to CAB, using only Textstream. New
CleanTEMP - Easily delete files from *all* TEMP folders. New 4-08
DOCtoTXT - Convert DOC files to text. Handy to shrink and simplify all of those
attachments sent by people who don't know how to use Notepad. New 4-08
Columnizer script - Converts a text file into 2, 3 or 4 columns.
Includes an option to choose how many lines are assigned
to a given column at a time. Demonstrates ReDim for arrays.
One limitation: Columns will only line up when using a monospaced font.
Download deskpack.zip (15 KB)
Back to Index
Shell.Application Ops - shellapp.zip
The Shell.Application object is not very well documented but has
some useful functions. The scripts in this pack demonstrate many
of the Shell.Application methods:
Various ways that BrowseForFolder can be used for selection of files or folders.
Enumerate open folder windows, getting path and coordinates.
Open folders and most of the items on the Start Menu (Run, Find, Shutdown, etc).
Also, put Windows into Suspend mode.
Run any Control Panel Applet if you know the CPL file name.
ALSO: A FileOpen browsing window displayed by using Internet Explorer to do it.
Download shellapp.zip (16 KB)
Back to Index
Windows System Info - sysinfo.zip
There are 4 scripts and a webpage here. All but one uses JSSys3.dll.
Three of these files are usable only on Win9x/ME. You don't have to use JSSys3.dll for
these scripts but you will need a means to read HKEY_DYN_DATA and
HKEY_CURRENT_CONFIG Registry keys. You'll also need a means to
enumerate Registry subkeys.
CPUdata - reports the current CPU usage. (9x/ME only)
Hardware info - compiles a list of installed hardware with information
such as driver date, manufacturer and INF file name. (9x/ME only)
Hardware9X info. webpage - a graphical version.
Display info - gets BPP, screen size, V. refresh rate.
IE Display info - Uses IE to get screen size and BPP info.
WMI Hardware Survey - Details installed hardware on all Windows
versions if WMI is installed. (New 5-08)
Download sysinfo.zip (11 KB)
Back to Index
Folder Tweaks Galore! (FTG)
Folder Tweaks Galore (FTG) has been replaced. FTG was
a script/HTML utility that provided an easy way to edit the folder.htt
file in Windows. Folder.htt is a webpage that controls the display and functionality
of folder windows. With FTG a number of extra functions and customizations
could be added. But these days most people are using Windows XP,
and unfortunately, Microsoft removed the "WebView" folder window functionality in
XP. There is no system-wide file folder.htt. Any appearance of WebView in XP
is just a fake veneer. (Pre-XP systems have an actual Internet Explorer browser
window in folders, which displays in accord with folder.htt. There is no browser
window in XP folders.)
That means that very little folder customization is possible in Windows XP.
In order to provide custom folder functions in Windows XP, an Explorer Bar
has replaced FTG. The Explorer Bar, jsFolderView +, is a free plugin that adds
a left-side panel in folder windows. jsFolderView + has 4 "tabs", providing a
number of options. Among them is a browser window tab for which you can write
your own custom webpage. In other words, it's the return of folder.htt for XP!
See the jsFolderView + page
for more information. There is also a link on that page for the old FTG package, in case anyone
using Windows 95/98/NT4/2000/ME still wants to use FTG.
Back to Index
EZPlanner - Webview Appointment Calendar
EZPlanner is a set of HTT and HTML files that create a small script-based program.
It's set up as a customized webview folder. When the folder is opened, instead
of seeing files you see an HTML-based program that includes and appointment calendar
and an address book. It's a bit hard to describe this.
See the picture here.
Download ezplan.zip (50 KB)
Back to Index
Thumbnail Viewer (and a drag-drop control)
This is an HTA Thumbnail Viewer with a drag-drop control.
There had been two other utilities here. One was a simple thumbnail generator script using
webvw.dll (used to display thumbnails in folder windows with Active Desktop). The other was
a utility to extract thumbnail images from digital camera pictures. The newer Thumbnail Viewer HTA
improves on both of those tools and incorporates their functionality.
The Thumbnail Viewer has several functions: Browse to a folder or drop a folder onto the
HTA to display thumbnails of all BMP, JPG and GIF files in the folder, showing file name and image size. Click a thumbnail to
show it enlarged. Drag a thumbnail into a graphic editor to open the source file for editing.
Print the display of thumbnails.
There are also adjustable settings for thumbnail size and thumbs per row.
Included in this package is JSDropCtl.ocx, a small and simple drag-drop control
which you are free to use. It's designed mainly for use in HTAs, to provide easy drag-drop
functionality. The control assumes the size of an assigned image. The image can be that of
a button, wastebasket, or anything else you like. And it can be any size.
View picture of the Thumbnail Viewer.
View picture of the Thumbnail Viewer showing enlarged image.
Download tnviewer.zip (29 KB)
Back to Index
Class Pack
This is a collection of class blocks for pasting into scripts. As classes they act as creatable,
external objects. The variables and private functions of the class are not visible to the rest of the script,
so no editing of the main script code is necessary. Just paste the class block at the end of the
script to add complex functionality.
Some of these classes are new in this pack. Others have been included
in other packs. Most of these come with two files: a heavily-commented demo script
and a compact, uncommented copy of the class for pasting.
ClsReg Easy functions for reading Registry values: Check for the existence of a key or value,
check the data type of a value, or return formatted data along with datatype. Enumerate keys and
enumerate values by exporting a .REG file. Return 4-byte
binary values as decimal numbers.
ClsINI contains 7 INI file functions.
ClsColors returns 6-character hex values for common system colors.
ClsExt returns path of default program for a given file extension.
ClsColPick uses an IE window to provide a 135-square color picker.
ClsMenu provides a multi-item popup menu, like a standard program menu.
(Requires IEMENU.OCX which comes with Win98/IE4 but is missing from some later OSs.)
ClsBrowse Improved versions of ChooseFile and ChooseFolder browsing windows.
(Replaces ClsFileOpen and ClsFindFol.)
ClsFileOpen uses an IE window to provide a system File Open dialogue; not as crisp
as the ClsBrowse version, which skips the IE window, but allows for graphical customizing and
informational text in the IE interface.
ClsFindFol This is an updated version of the BrowseForFolder scripts in
the ShellApp pack. There's an option to also show files in the browsing window.
The Browse function returns path of selected item and whether it's a file or folder.
If a file was selected this class also makes sure that the file extension is included
in the path (a problem on systems with hidden file extensions). With those extra
functions ClsFindFol can be used as a File Open dialogue, as well as for folder selection.
ClsPaths A compact class that uses a combination of 4 different methods
to return system folder paths - for current user or all users - on all Windows versions.
Download claspak.zip (61 KB)
Back to Index
CWMIReg - WMI Registry Class
The Registry class in the Class Pack download (above) provides a convenient wrapper for
WScript.Shell functions. (RegRead, RegWrite, RegDelete.) But those functions are limited.
WScript.Shell cannot write long binary data or enumerate keys and values. WMI has the
StdRegProv object for full Registry access, but like most of WMI, StdRegProv is awkward and
poorly designed. This class combines the functionality of StdRegProv with the convenience
of WScript.Shell. Finally, it's full Registry access for scripting with simple functions:
Exists, Delete, CreateKey, SetValue, GetValue, EnumKeys, EnumVals. The only disadvantage
is that WMI must be installed and running, but that will not be an issue in most cases.
The download here includes a copy of the CWMIReg class, as well as sample scripts for
all functions and an HTML-based help file. The class can be pasted into your script or
loaded from a separate file using the ExecuteGlobal function, which is demonstrated
in the sample scripts.
Download wmireg.zip (18 KB)
Back to Index
Recursion Scripts
Several scripts that will search a folder and all subfolders, creating a list
of all files with a given extension, all files modified since a given date, etc.
Download recurse.zip (5 KB)
Back to Index
Enumerate Installed Software
There are two separate things in this package:
1) A script that includes three functions for enumerating installed software
on any Windows version without needing WMI. It lists (1) software installed via Windows Installer,
(2) software listed in the Registry
App Paths key, and (3) software listed in the Registry Uninstall key.
2) A webpage and a script that together constitute a GUI interface
for exploring software installed via the Windows Installer. The script contains
a class that can also be pasted into other scripts. The class structures Windows Installer
information as a COM object that can be created. Given a W.I. Product ID you
can return a "Product" object from the class, the properties of which contain extensive information
about the given installed software product. The Product object exposes properties
such as Company name, installation date, installed features, components, and files, etc.
In other words, by pasting this class into your script you can access extensive,
organized information from Windows Installer without having to deal with the tedious,
convoluted structure of the Windows Installer object model.
A note about WMI, Windows Installer and installed software:
If you use WMI you may be familiar with the Win32_Product object
for enumerating installed software. WMI software listings are derived from the same
Windows Installer system explained above. Both WMI and the class in this script package
are limited in that they can only retrieve information about software that was
installed using Windows Installer, which is usually a fairly small subset of installed
software.
The advantage of this class is that it does not require WMI. It uses plain
VBScript, going directly to the Windows Installer COM object and cutting out the WMI "middleman".
Through MSI.DLL (The Windows Installer COM interface) you can know the files, Registry
settings, and virtually all other relevant details about installed software.
JSSys3.DLL is required for the first item, the 3-function script.
Download listsoft2.zip (16 KB)
Back to Index
Weblog Script
This is a template script for getting hit counts from raw server logs.
The script processes the raw log file, counts hits for as many files as desired,
then writes the info. to a local log file. (Script editing is necessary.)
Download weblog.zip (4 KB)
Back to Index
Explorer Script and Webpage
This is a webpage that displays a functional old-style explorer window
(the type with listboxes for drives, folders and files). It uses 3 SELECT
elements in combination with VBS to do that. The webpage has a button to
open a selected file. There is also a script version that creates a similar page
and functions as a FileOpen dialogue, returning the path of the file selected.
The script is not a very good way to make a FileOpen dialogue but it might
be of interest for the IE scripting.
Download explorer.zip (10 KB)
Back to Index
Startup Manager Utility
This is a full-scale startup manager in the form of a webpage. It requires the
current version of JSSys3.dll (v. 3.03.0216) and is also included with the JSSys3 download.
The Startup Manager webpage checks the Registry, the Startup folder and the WIN.INI file
to compile a list of programs set to run at startup. It also does what all startup managers should,
but usually don't, do: it provides file information needed to identify the executable set to run at
startup. Any item in the list can then be removed.
While the Startup Manager requires JSSys3 for certain operations, much of
the functionality is made possible by the flexibility of the IE DOM.
Download startman.zip (14 KB)
Back to Index
MSI (Windows Installer) Utilities and Code
Windows Installer is a method of software installation, increasingly used by
Microsoft. It packages program installations into an MSI file that contains
a database holding all information about the installation. The idea, apparently, is
to have a single, dependable system of software installation that allows network
administrators to track installations more efficiently. The actuality is a remarkably
abstruse and superfluous complexity that leaves programmers and end-users alike
virtually unable to know or control how software is installed and what files
are included in a given program.
On the bright side, there is a fairly complete, script-accessible MSI automation interface -
the WindowsInstaller.Installer object. Script can access that object to unpack and edit
MSI installer files. Not only that... Any MSI file can be used as an SQL database.
The MSI scripts now have their own webpage. There is an MSI unpacker utility (webpage program),
an MSI database editor (webpage program), a free MSI-based US zip code database (webpage program),
and a script for customizing installer files.
See the MSI code page for all of that.
Back to Index
IE MD - Internet Explorer Configuration Utility
The IE MD is a webpage program, comprised of several HTML pages and VBScripts.
It all comes packed with a script-based installer. The IE MD provides access to
numerous settings and information for Internet Explorer.
See the IE MD page.
Note: The IE-MD may not be compatible with IE7. There are no plans to update it. See below.
Back to Index
VBS Object Browser Utility
This is a webpage-based object browser made using HTML and VBScript.
An object browser can read type library information to show you what
methods and properties are available from an object. This script-based version
works surprisingly well. It processed the entire IE DOM in MSHTML.TLB
in just a few seconds without overloading WSH.
This utility works by taking advantage of the functions available in the Microsoft library
TLBINF32.DLL which installs with Office and Visual Studio. If you don't have
that file installed you'll need to get a copy of it.
There is also a very good help file for TLBINF32.DLL. You should be able
to get it at this link.
View picture
Download obbro.zip ( 20 KB)
Back to Index
Browser Ad-Blocker Script (Uses the HOSTS file)
The HOSTS file can be used on all operating systems, and with all browsers, to override IP address
resolution in the browser. That means it can be used to block your browser from contacting any number
of specific websites by simply predefining those URLs as being on your computer. This script is a utility that makes it easy to add
URLs to your HOSTS file while browsing, for the purpose of blocking 3rd party
ads and web bugs.
Some people may feel that it is not fair to block ads from websites,
since those ads provide an income to the webmaster.
The HOSTS file cannot be used to block legitimate ads that originate from the website
you are visiting. But it can be used to block 3rd-party ads, from ad-servers, that may be
used surreptitiously to track your behavior and identity online.
More info. and download on the Internet Privacy Tips page.
Back to Index
Binary Operations and Base64 Conversion with Textstream
This is a script class, ClsBin, that uses the Textstream object, combined with various string and
array functions, to carry out binary operations. It is generally thought that VBS does not handle
binary files (except through later versions of ADODB.Stream, which is not universally installed).
Actually, the Textstream can handle binary files just fine. It just needs some special treatment
to deal with "null" characters. In the Windows API, nulls [Chr(0)] are used to mark the end of
strings. As a result, while Textstream has no trouble reading or writing a string that contains nulls, the nulls
cause problems when you try to read text from the string or perform operations on it.
ClsBin provides a set of workarounds that make it possible to read and write file
bytes as both numbers and text, making it possible to perform any typical binary file operation.
Functions in the ClsBin class:
Read and write binary files.
Binary file helper functions, such as converting 4 bytes to a number.
Convert to and from Base64.
Get File Version Info. for PE files
(EXE, DLL, OCX. etc.) This is the info.
that shows on the Version tab of the file's Properties window, such as Description, CompanyName, etc.
A sample demo script uses the class to lighten a bitmap file image.
Download ClsBin package (tsbin.zip) - 52 KB
Notes about working with binary files
The JSBin.DLL component (see below) is an easier, more efficient
way to work with binary files, but the ClsBin class can do it without any extra components.
The JSBin.DLL download may also be of interest for more binary sample scripts if you
download this package.
Also of interest may be the File Version Information Class and the Icon Extractor
script (below). Despite the fact that VBScript cannot access the Windows API, all of these scripts demonstrate
ways in which VBS can often be used to bypass those same API functions. The File Version Info. class achieves
what normally requires a call to the API function GetFileVersionInfo in VERSION.DLL. And the Icon
Extractor does the equivalent of calling the ExtractIcon function from SHELL32.DLL. Both scripts work
by bypassing the level of the Windows API to operate at a lower level - the basic level of reading, writing
and manipulating bytes.
Note About DBCS (Asian) Languages With Respect to Textstream and Binary Files:
If you work with Asian-language systems there is a limitation that you need to be aware of,
regarding the use of the Textstream object to read and write binary files. DBCS (double byte character set) languages,
such as Chinese, Japanese and Korean, pose an extra challenge. One of the official Microsoft scripting experts, Eric Lippert, has
written about this issue in his "blog".
Unfortunately, if you have read that posting you may be left confused about how and
where Textstream binary operations will work. Mr. Lippert is somewhat forceful in asserting that Textstream
does not really work for binary functionality. But that is simply not true. As a result, his explanation of Textstream limitations is
a bit misleading and generally uninformative. The following explanation is an attempt to clear up any confusion.
The Textstream methods of CreateTextFile and OpenTextFile both have an optional
format parameter. If format is not specified then it defaults to ASCII. So Textstream is normally treating
all files as ASCII files, generally representing each byte as a character. If you look at
any file in a hex binary editor you will see the contents represented as a series of numeric byte values, from 0 to 255.
If that file is a plain text file then the bytes represent characters. For
example, in English the byte 84 is "T"
and 116 is "t". The ASCII system uses the "local codepage"
to define the character assignations for bytes. That means that a series of bytes in a text file will be
translated according to the default language on the local system. With most languages, each byte represents a
character and Textstream can be used to handle those bytes as binary data without a problem.
In the case of DBCS
languages, the 256 values possible in a byte are not sufficient to represent all
characters. That problem was dealt with by designating some bytes as escape characters in order to
increase the number of possible characters represented in ASCII text. In other words,
for example, a byte value of 51 might represent a particluar character by itself, but represent a different character
if the 51 is preceded by, say, byte 88. That means that there is not always a one-to-one correspondence between
bytes and characters in DBCS languages.
With European languages this DBCS complication is not relevant.
However, if your computer's default language is set to Chinese, Korean, or Japanese - or if you want to send scripts to
someone with a PC defaulting to one of those languages - then in order to use the ClsBin class you would need to adapt the functions
to account for the escape characters of that language. (Probably you would need to use something like a Select Case
when translating to/from characters/bytes in order to catch the special escape characters/bytes as the
data is being processed.)
Back to Index
File Version Information Class
This is a class that can be pasted at the end of a script to provide file version information
functionality for PE files (EXE, DLL, OCX). Normally there is no VBScript method to return the information that shows
when a file is right-clicked, then "Properties" is clicked, and the "Version" tab is selected.
This class is condensed from the code in the Textstream Binary Ops scripts (above) to provide
a compact, pastable class that returns FileVersion, CompanyName, FileDescription, etc.
Download ClsProps package (filprops.zip) - 12 KB
Back to Index
The Running Process List
The running process list refers to all programs ("processes") running. That includes programs ("tasks")
that show in the Taskmon window when [CTRL+ALT+DEL] is pressed, and it also includes services.
This package was specifically designed for people who want to check for spyware, viruses, etc.
by investigating the software that is currently running on their computer. Having access to the list of
running processes is useful in guarding against undesirable software on your system because nearly all
such software runs in the background and is therefore in the list of running processes. Since "malware"
is usually set to run all of the time, it can be caught in the act. (But note that kernel rootkit software will not show
up in the process list.)
The download includes a script that details the running processes by using JSSys3.DLL (included). Also included
is an information HTML file that explains how to use the script.
Download ProcLister script (procs.zip) - 73 KB
Back to Index
DOM-Editor: A script-based HTML editor
DOM-Editor is a "What-You-See-Is-What-You-Get" webpage editor made with
VBScript. It uses a webpage with 2 sub-frame pages to create a highly functional HTML editor
powered by VBScript, using only the IE Document Object Model (DOM) to accomplish
all the operations needed.
DOM-Editor is not meant to be a superlative
HTML editor. Rather, the idea is to provide sample code for various
IE DOM methods. The IE DOM is vast and it is difficult to find thorough documentation for it.
This editor provides a way to demonstrate many of the IE DOM methods, and also
serves to demonstrate the remarkable flexibility of the IE DOM.
Included methods: TextRange object operations, Body, Window and Document ops,
getAttribute, setAttribute, showModalDialogue, working with HTML Elements, etc.
View picture
Download DOM-Editor (domedit.zip) - 53 KB
Note: This script may be partially incompatible with IE7. See below.
Back to Index
Icon Extractor
This is a set of scripts that extract icons from PE files (EXE, DLL, etc.) They're based on the
PE file functions used in the File Version Info. script (above). This script uses only
the Textstream object to read the resource table structure of a PE file and extract
the icon resources listed there. One script will extract icons of 9 different common sizes and
save them as ICO files. (Drop SHELL32.DLL onto this script to see what it can do!
It works surprisingly fast, even with files containing hundredss of icons.)
The 9-08 update adds another script that extracts and reconstitutes
whole compound icon files. In many cases an icon file may contain multiple icons in
different sizes. The updated version script recreates those files. Whether the .ico file
has 1 icon or 10 icons inside, each icon is extracted accordingly as it was stored in the
PE file resources. (By contrast, the original script just extracts all icon images, creates
file headers for them, and then writes them to disk individually.)
Download Icon Extractor (iconex.zip) - 32 KB
Back to Index
Roll-Your-Own StartPage (with download component)
See the RYO StartPage page for this. It includes
a file download component (ActiveX EXE) and sample script. The whole package is a
script-based RSS news reader that creates a custom start page based on selected RSS links.
The source code for the main body of the component, jsTP.exe, is also available on
the VB Code page as a VB6 file download UserControl.
Back to Index
Custom Message Box

This is a customizable message box made with Internet Explorer.
If you want something snazzy, see the JSDraw.DLL component, which allows you
to make a "skinned" message box. If you want something simple that mimics a system message box, then you might find
this useful. It is a small VBScript class that can be pasted into a script to provide
a message box object with several custom options. It uses the default system colors in
an Internet Explorer window to produce a close facsimile of a system message box.
This message box is self-sizing, with an option for using an icon image,
font choice, unlimited number of buttons, etc. It is very easy to use. You just create the
object, add the parts that you want as properties (caption, icon, buttons, etc.), the display the
window.
Update Note Feb-06: A new version of the Custom MsgBox adds options to include a list (listbox or
dropdown selector) and/or text input in message box windows. The download now includes all versions: The original custom message box,
a version of the old message box that can display common XP "skins", and the new, updated message box.
View more custom message box samples.
Download Custom Message Box Class (msgb.zip) - 50 KB
Note: This script is incompatible with IE7. See below.
Back to Index
XPFix - Various VBS/WMI Utilities for Windows XP
...Fixing services bloat, folder dysfunction, and various other XP problems...
These utilities have their own separate webpage. There are currently two downloads,
which both involve HTA webpage programs using VBS and WMI:
XPFix - A general tweak/fix utility for Windows XP that uses VBS and WMI. The idea
with XPFix is to provide a quick way to fix some
of the problems on a default XP install, and add back some of the useful things that are missing from XP.
XPFix provides an easy, informative interface to disable numerous risky XP services. It also provides
a few simple tweaks to make XP more usable. They include disabling
many of the "babysitting" and nagging functions, as well as adding such handy features as right-click
"Open with Notepad" and right-click "Open in New Window" (for folders).
XP Folder Fix - Ever notice how Windows folder size and view preferences never seem
to stick? It's been like that since Windows 95! Folder windows are one of the most basic points of interaction for people
who use Windows, yet Microsoft has never provided a simple, sensible way to dependably choose size, position, type
of display, etc. for folder windows. It's a prime example of the basic problem with Microsoft products: If Microsoft
were selling cars, you wouldn't be able to drive the MS Roadster to NYC. Why? Because NYC is not a safe place to
go and you're not capable of deciding that issue for yourself. So that functionality has to be hidden away where only
brazen, determined and reckless "tweakers" will find it.
In Windows 95/98/2000/ME, folder window size can be controlled with just
a couple of lines of script in the folder.htt file that controls "WebView" folders. It's an obscure
tweak, but an easy one. With Windows XP, Microsoft removed the WebView functionality
and folder view control has degenerated into a bizarre, nonsensical tangle of Registry keys.
The new system is not only an overkill of complexity (as usual) but it's also just plain broken.
Under normal circumstances Windows Explorer records settings for all folders ever opened -- then
ignores them!
XP Folder Fix consists of an HTA program that allows you to select size and view
for all previously opened folders. ( UPDATE 2/09: There's also a drag/drop script for fixing new folders
as you make them.) XP Folder Fix uses VBS along with the WMI StdRegProv object
to untangle the mess in the Registry. (There are potentially thousands of Registry keys involved.)
Back to Index
Retrieving JPG File Info. - Exif, IPTC, Thumbnail, Summary
JPG files have file header specifications that provide the option to store various
data in the file. This script uses only FSO and Textstream to extract 4 types of
JPG data. The basic code includes 3 classes that present JPG file data through
two custom objects. The total code is only about 20 KB, so it can be pasted whole into
other scripts to add JPG header parsing functionality. (Note that not all JPG files have all types of data stored, and this script can only
retrieve, not save, such data.)
Exif tags - data stored by digital cameras that describes the camera and settings used to take a photo.
Summary properties - Five comment strings that can be saved/viewed on Windows XP in a file's Properties window -> Summary tab.
Thumbnail - a thumbnail copy of the image that most digital cameras store in the file header.
IPTC strings - data such as photographer name, location of shot, etc. that can be saved in JPG files.
Download jpginfo.zip (18 KB)
Back to Index
Sudoku Solver
Would you like to impress a potential employer or lover with your sudoku expertise?
Perhaps a loved one has succumbed to the sudoku craze, convinced it will somehow
make them more intelligent, and you want to thwart them by filling in their entire sudoku puzzle
book "for their own good"? Then Sudoku Solver is what you need. This is an HTA program
that shows a sudoku grid, allows you to enter the pre-existing puzzle numbers, then solves the
puzzle. It may have limited uses, but it's somewhat interesting in terms of the scripting
challenge. It turns out that the code for this is not terribly complex.
Download sudoer.zip (13 KB)
Back to Index
Sorting Demo
Sorting here refers to alphabetical (or numeric) sorting of array elements. VBScript can
sort an array of words alphabetically with surprising speed. Using the scripts in this download, a
QuickSort routine sorted 70,000+ words in under 3 seconds. (Running on Win98SE with Sempron 1800 Mhz.)
More typical sorts are virtually
instant. QuickSort is also a very simple routine. Yet there is a lot of advice online to the
contrary. Even "The Scripting Guys", who are the official Microsoft VBScript experts, suggest
the abominable BubbleSort
or even worse, a .Net method!
BuubleSort is so bad that we didn't even test it on larger arrays. In cases where QuickSort took less than 1
second, BubbleSort still hadn't returned after a matter of minutes. And using .Net these days requires installing
a runtime dependency of over 200 MB. QuickSort only requires a sub of about 20 lines.
The download here includes an explanation of the tests, scripts to test 5 sorting methods,
and 3 versions of QuickSort. (For case-sensitive, non-case-sensitive, and 2-dimensional array sorting.)
Download sorting.zip (7 KB)
Back to Index
CodeLib - Code Sample Database
CodeLib is an HTA program (the visible part) combined with an MSI file (the database part).
It's a flexible, searchable database wherein one can store code samples for script, programming code,
HTML, CSS, or anything else. Choose a language and CodeLib loads a list of stored sample names.
Click a sample name to load keywords, description and the actual code sample itself. The database
can also store files, such as type libraries, ActiveX controls, etc.
CodeLib is a simple, orderly way to catalogue your favorite scripts and snippets.
It also provides a way for people to share code libraries between themselves.
View a screenshot of CodeLib
Download codelib.zip (96 KB)
Back to Index
Components
|
These are DLL files. Once registered on your computer, they provide an object that exposes functions.
The object can be accessed with "CreateObject".
These components require the VB6 Runtime Files. (There are links on the WEB-ED and Tweak Revisited pages
if you need those.) Each component comes with documentation, sample code and a VBScript that can register or
unregister components. That script also has tips (in the comments) for automating a remote
component registration.
|
JSDlgBox.dll - Browsing dialogue component
The JSDlgBox component provides browsing dialogue windows for use
in VBScript. The functions are simple with no optional arguments
Browsing windows available: File Open, File Save, Choose Color.
Functions will show the dialogue window and return the file name or
color chosen. (Note: These functions have been added to the JSSys3.dll
component.)
Requires VB6 Runtime Files.
Download jsdlgbox.zip (8 KB)
Back to Index
JSListVw.dll - List box window component
The JSListVw component provides a list box window
and several functions to deal with files and folders.
Functions include getting a list of:
All files in a folder.
All folders in a folder.
All files that were created and/or modified on a given date.
All folders that were created on a given date.
All files with a given file extension.
The list can be added to, cleared, or viewed in a window. List items
can be retrieved as an array or formatted string. An item can be
selected from the window list and the path of that item can be retrieved.
There is a script included that covers all the functions.
Requires VB6 Runtime Files.
Download jslistvw.zip (18 KB)
Back to Index
JSForm.dll - GUI component
The JSForm.dll component provides a variety of interface options.
It provides a scriptable window with options for:
Window Title
Window Caption
Icon
2 textboxes (one of which may be a multi-line box of any size)
Listbox
Browsing dialogues (FileOpen, FileSave, BrowseForFolder, Color Selector)
Buttons - up to 3 buttons with any caption
Audio (play wav files)
Color options - set colors of window, window text and buttons
Save settings - INI file functions
Any or all of these options may be used in a given window.
There are numerous properties that can be set and functions to return
button clicked, textbox text, listbox selected item, etc.
Click Here to see some window samples.
Requires VB6 Runtime Files.
Download jsform.zip (70 KB)
Back to Index
JSSys3.dll - System info. and operations component Updated 10-29-09
The JSSys3 component provides system functions that are difficult to
access or unavailable through VBScript. It contains 2 objects, Ops and IniEdit:
Functions in the JSSys3.Ops object -
Information: Get Current User, computer name, display info., memory usage,
OS version, default program for filetypes, paths of executables.
Registry: Read data from 6 registry keys (all except NT HKEY_PERFORMANCE_DATA),
write data (including long binary), enumerate keys, enumerate values, delete values,
delete keys(including keys on NT that have subkeys).
Given a ProgID or CLSID, check whether a class is registered and, if so, return
CLSID, ProgID, file path.
Display: Get and set system GUI colors. Change wallpaper.
Processes: List running processes, list open windows, get active window,
set active window, close a window/program.
Dialogues: File Open (with multi-select option), File Save and Choose Color
browsing dialogues. (Including optional file extension filter setting.)
Miscellaneous: Shutdown, reboot or logoff. Get and set clipboard text.
Play a WAV file. Print files with default program. Timer(time count, not event.)
PEFile Object: An object available through the Ops object that represents file
property information for PE files (EXE, DLL, etc.) such as version, company,
file description, etc.
Functions in the JSSys3.IniEdit object -
The IniEdit object provides a full selection of operations for reading
from and writing to INI files.
Functions in the JSSys3.StreamOps object -
The StreamOps object provides functions to enumerate, read and delete alternate data stream files
on NTFS-formatted partitions. (ADS files are hidden security risks.) An included sample script
will recursively list all ADS files in a folder or disk partition. It can easily be adapted to clean out all
ADS files on a PC in a few seconds.
There are 15 demo scripts and a full help file included in the download.
The Startup Manager and Win9x system Info. webpage utilities are also included.
Update info 10/29/09: The latest update adds the StreamOps object and a minor bugfix.
Download jssys3.zip (129 KB)
Back to Index
JSBin.dll - Binary Operations component
JSBin.dll provides binary file functions. They're of limited use in
scripting but if you need access to binary files this should do it.
Functions include:
Write to and read from binary files.
Translate multiple bytes to number and vice versa.
Translate byte numbers to binary strings and vice versa.
Convert between Base64 text and binary.
Sample scripts include bitmap operations, creating an icon from
a bitmap, and getting a list of functions from DLL files (export table).
Requires VB6 Runtime Files.
Download jsbin.zip (35 KB)
Back to Index
JSDraw.dll - Drawing component
JSDraw.dll provides drawing capability to VBScript. This functionality
is in 2 parts:
1) Draw directly onscreen using shapes, text and images.
2) Draw to a built-in window that can be used for custom popup messages.
JSDraw can draw lines, shapes, text and images from files. It can also
be used to save a screen capture of any or all of the Desktop, allowing
drawn graphics to be saved. All of the same methods can also be used
with the popup window and the popup can have up to 4 defined hotspots
to receive input from mouse clicks. In other words, the popup window is
any kind of message box that you want it to be.
View sample drawing
Download jsdraw.zip (56 KB)
Back to Index
JSMail.exe- Email component
Updated 4-08
Send email - plain text or HTML, with or without attachments. Send HTML webpages directly
as HTML email. No email program needed. No dependencies. Compatible with Windows 95/98/2000/ME/XP.
JSMail.exe is a component for sending email. It does not require MS Outlook, MAPI,
CDO or other emailing software. JSMail uses the system
sockets library Wsock32.dll. It sends email by communicating directly with your
outgoing mail server, taking the place of an email program.
JSMail.exe can send plain text or HTML email. With plain text it can also send
attachments. With HTML it can email a webpage with embedded pictures. Note that this component
still requires an SMTP server. It does not replace the server. It replaces email software.
New in v. 2, April, 2008 update: JSMail v.2 adds the ability to send
to multiple recipients. Also new is an HTA webpage program intended especially for people who
know some HTML and CSS. Do you ever want to design a webpage and then just send that as an
email? The HTML email facilities in common email programs like Thunderbird or Outlook Express are extremely limited,
providing little more than the ability to color text with a few common colors and choose among a few tacky
"stationery" options. With the SendHTML program, an HTA utility "powered by" JSMail,
you can just write a normal webpage. SendHTML.hta is included in this download. It provides a
handy graphical interface, using JSMail to convert an HTML file to email format and send it. The
SendHTML program will recognize IMG tags, BODY BACKGROUND
images, and
images specified in the STYLE background-image property of a webpage. It embeds the images in your email
so that your webpage is delivered to the recipient just as you designed it.
Using the
SendHTML.hta program is as easy as filling in a few text fields in a webpage. (An HTA program
is an interactive webpage that runs locally in Internet Explorer.) There is also an option
to output the entire email server communication to a text window in the SendHTML
page. That ability can be useful for troubleshooting.
Download jsmail.zip (71 KB)
Update notes:
1) While the SendHTML.hta utility can send webpages as email directly, some email
programs may not fully recognize your HTML/CSS. Testing might be needed. In our tests, Outlook
Express 5/6 and Apple Mac email rendered HTML emails properly, recognizing and rendering all 3 webpage image types (background
image, inline image, and STYLE-designated background image for elements such as HTML headings), but Thunderbird
did not see a background image assignment in an H2 tag using the CSS background-image
property. (Outlook Express would also miss the background-image property if it were applied inline
as an H2 tag STYLE attribute, rather than
within a STYLE tag.)
Thunderbird seems to be somewhat buggy when it comes to properly displaying images in HTML. And ironically,
"webmail" browser-based email, such as gmail or yahoo webmail, seem to be the worst in terms of recognizing
and processing CSS code. So there are some details like that to keep in mind, but in general you
can expect basic webpages sent with JSMail to render as expected for the recipient.
2) Bugfix note: For people with experience using JSMail: Have you used JSMail before? Have you ever experienced WScript
crashing at script end? If so, download this latest version for corrections in the sample script. There is no problem
with the older version of JSMail itself, but the older sample scripts could cause a script crash in some circumstances.
VB6 code option:
VB code is also available for this, in the form of a VB UserControl.
The VB code is essentially the same as the JSMail component, but it can be compiled into VB software to provide
built-in email capability. The VB code does not use any controls, such as the Winsock control.
It is straight VB and sockets API. The UserControl incorporates Base64 encoding for attachments, email formatting, server IP resolution,
etc. In short, it is a compact, soup-to-nuts, emailing engine that can be dropped into any VB project to
provide emailing functionality with no dependencies, on Win95 through XP.
Back to Index
jsHTTP2.exe - File Download and IP -> Hostname component
Note: jsHTTP2.exe replaces jsHTTP.exe. In addition to added functionality there were
slight function changes in the new version, so it has been created as a new file/object. (The
changes to the object model are very slight, mainly just involving improved error reporting.)
jsHTTP2.exe is a component designed to combine various Internet-related functions.
It has three main objects at this point:
Downloader - Download files without any dependency on IE, MSXML, or other high-level wrappers.
IPInfo - Designed for webmasters, IPInfo provides functions to get host name and
geographical location from an IP address. The host name resolution function is optimized
for processing a large number of IP addresses. It has a timeout option to prevent long
lags when web servers don't respond to a host name request.
Included is a sample script for auto-editing web server
"raw" logs in order to see where your visitors are coming from. For example, a log entry with
an IP like 40.40.40.40 might be translated to
something like server.acme.com*East Oshkosh-WI-US.
(IPInfo uses a free database and component from MaxMind, at maxmind.com, to find
geographical location data. Thank you to MaxMind for your generoisty and well-designed tools.)
FileOps - Provides zlib compression functions and .gz file creation/extraction. Also
includes a large set of high-efficiency file I/O functions. There are already two packages here
for binary file functions: One based on Textstream and also jsBin.DLL. jsHTTP2.FileOps is a bit
different. It bypasses the slow, awkward process of translating bytes to and from variant
data types (required by VBScript) by providing functions to handle, store, read, write and edit
byte streams as stored objects. You can read a binary file, edit it, and write it back to
disk without actually "touching" most of the byte data in script.
Download jshttp2.zip (146 KB)
Back to Index
jsrssv.exe- RSS component
jsrssv.exe is a component for downloading and processing
RSS files from web feeds. It has functionality to download files,
write downloaded files to disk, and process files as RSS text,
returning an RSSFile object that provides access to the feed elements
through an RSS object model. jsrssv.exe can be used to download and
custom-format RSS feeds.
This is currently a beta component that has had limited testing.
Feel free to email with questions or reports about your experience using it.
(See the VB code page for an OCX ActiveX control equivalent with source code.)
Download jsrssv.zip (37 KB)
Back to Index
RTFtoText Conversion Component
jsRTF.exe is a simple component that can be used to process RTF text in script. RTF
text is Rich Text Format, the text with formatting information used in WordPad and in
RichTextBox controls. RTF records information about font, text color, text size, etc. in
the text itself. A RichText window, such as WordPad, can load RichText and display
the formatting. (MS Word uses similar functionality.)
jsRTF provides functions that mimic the Textstream object. An RTF file
or string can be loaded as a stream and then read from, or written to disk, as the plain text version.
Download jsrtf.zip (23 KB)
Back to Index
Type Library Reader Component
jsCOM.DLL is a component for reading and documenting type libraries, with a particular
emphasis on information relevant to scripters. jsCOM is similar to the object browser
script above. It is not a replacement for the object browser script but rather a replacement
for the file that script uses, TLBINF32.DLL, which is not installed on all Windows systems and
is very difficult to work with, especially for scripters. TLBINF32.DLL is the component used
to display an object browser in Visual Studio and MS Office. An object browser is
a utility that displays the methods, properties and events in scriptable COM objects.
jsCOM.DLL reads type libraries (the system documentation that makes
COM possible) and then provides a usable object model of
the information found there. You can use it to make your own object browser; to list, for example, the methods of FileSystemObject, find
out what file it derives from, find out whether it's installed locally, check for the existence of
a specific method, retrieve the values of all FSO constants, etc.
Download jscom.zip (36 KB)
Back to Index
JSProgBr.exe - Progress Bar component
This is a simple progress bar component. It's made as an ActiveX EXE
so that the progress bar can run independently of the script. There are
30 units of measure. Draggable title bar. Title and caption can be changed
while running. The window can show an icon. The window can optionally
be shown center screen and/or on top of other windows. Progress can
be set to proceed automatically with a timer (using WScript.Sleep).
Note: JSProgBr is still available but it was actually
replaced by JSProgBr2, which provides more options.
Download JSProgBr.exe (13 KB)
Back to Index
JPG IPTC Component
jsIPTC is a component that can read and write 12 different string properties
stored in JPG image files. IPTC is a standard established by the Newspaper Association of America (NAA)
and the International Press Telecommunications Council (IPTC). It is a standard for storing
"metadata" information strings in JPG files, and is recognized by IrfanView and Photoshop, among others.
jsIPTC can be used for searching and/or cataloguing image file collections. Updated 10-08.
Download iptc.zip (41 KB)
Back to Index
jsRTB - RichTextBox Control
jsRTB is a RichTextBox control for use with VBScript. Unlike the Microsoft
RichTextBox, jsRTB does not require a license. It uses properties and methods with variant
parameters in order to accomodate script. It can be embedded in a webpage with an
OBJECT tag. And it has nearly all the functionality of the Microsoft RichTextBox - plus some extras.
(jsRTB is recommended for use in HTAs. The control is not "safe for scripting" because it
can be used to edit and write files on disk. Therefore it cannot be used in public webpages.)
jsRTB is basically what you would have if Wordpad were a scriptable
ActiveX control. It allows you to provide full editor functionality, with control over
all of the editor operations. The download comes with a simple text editor demo in the form
of an HTA. The demo is similar in functionality to the Wordpad program.
Download rtbocx.zip (50 KB)
Back to Index
jsCAB - CAB File operations Component
jsCAB is a component to enable working with CAB files. It can be
used to create and unpack CAB files, to get information about CAB files, and to
convert a self-executing CAB file (EXE) to normal CAB file (CAB). The download includes
working drag/drop scripts for all operations.
This download also includes a C++ DLL for use by programming
languages such as VB. (The COM component jsCAB.dll embeds the C++ DLL,
providing both script-friendly COM functions and standard DLL functions.)
Download jscab.zip (76 KB)
Back to Index
ShellApp2 - Shell operations component
When it comes to the Windows Shell, the native functionality for scripters
is a buggy patchwork. The Shell.Windows collection provides
access to open folder windows, but that access is only in terms of folder
windows as a kind of faux Internet Explorer object. And the Document object of that fake IE object
is a dummy object with few, if any, properties. Likewise, Shell.Application provides access to some folder properties
through the Folder object, but the Folder object is undependable, often not "seeing" many of the
files in a folder.
ShellApp2.dll is a sort of enhanced Shell component.
It provides an enumeration of open folder windows or open IE instances.
In the case of folder windows, it provides information about files and subfolders, selected items,
focused item, etc.
It also provides access to the ShellFolderView object, the Shell Folder object,
and the real IE Document object for a Web View folder.
Additional functions include returning the IE object and the IE Document
object from running instances of Internet Explorer, and returning the Document object
from running HTAs. This component allows dynamic scripting of open folder windows, running
IE instances, and running HTAs.
Windows XP Note: The Document object for open folder windows is available on all
Windows versions with Active Desktop Web View folders - Windows 95/NT4/98/2000/ME - but it
is not available on Windows XP. XP does not have true Web View folders. They are called
"Web View" but a true Web View folder has an embedded IE browser window, while an XP
folder view is actually just a return to the original, plain Win95 folders, with some added menus.
Since there is no actual Web View in XP there is no Document object for Folder windows in XP.
However, the ShellFolderView object, and the Shell's Folder object -
or at least emulated versions of them - are still operational on XP.
See the extensive, included help file for a fuller explanation.
Update note: 9-22-07: The function to return an HTA Document object was updated
to account for a bug in HTA functionality that would cause the function to fail in certain scenarios. A full
explanation is in the updated help file.
Download shap2.zip (42 KB)
Back to Index
jsAA - Active Accessibility component
jsAA.dll is a component for use with script or compiled software. It is designed as a "wrapper" for Microsoft Active
Accessibility (MS AA). The main use of the AA API is for use in screen readers for the blind. It can also be used
to control and automate Windows. AA provides methods to know what is onscreen, what has focus, etc. It can
return the content of textboxes and the captions of buttons. It can set focus to a given object or simulate a button click.
jsAA can provide AA info. from a point onscreen, from a specified open window, or from events as they happen.
It can also report keystrokes as they happen. jsAA presents the awkward and difficult AA API in a simpler object model.
Working with AA can be frustrating because it's really an unfinished technology and Windows is not
consistently designed enough to work well with AA. As a result, commercial screen readers have to use
a wide ranging set of methods and hacks -- in addition to AA -- in order to do their job. But with jsAA at least
the AA API is easier to deal with.
There are sample scripts in the download that do things like audibly describe GUI events as they happen
and audibly describe the elements in an open window.
Download jsaa.zip (88 KB)
Back to Index
jsMSI.dll - Windows Installer/MSI Ops
jsMSI.dll is a component for use with script or compiled software. It wraps the clunky and tedious Windows
Installer API, providing relatively simple functions to open, edit and unpack .msi files.
Windows Installer
provides a Dispatch or "late-bound" interface for scripting. It also provides API functions. jsMSI.dll uses the API
functions internally and provides 2 objects -- one for scripting and one for compiled software. jsMSI provides methods
to import/export tables, find column and table information, add or remove records, edit column values, extract or
insert embedded files, extract files from CABs, etc. It also provides a single function UnpackMSI that
does just that, unpacking an MSI installer while documenting the installer package, including Registry settings made by the installer.
jsMSI.dll does not add anything new that the JSWare MSI-related scripts cannot do, but it provides
a library using API functions for people who may want greater speed and efficiency, or who want to
use the functionality in their own software. jsMSI basically combines the functionality of the 1-click MSI unpacker
with the functionality of the MBase scripting class. One can easily build a software GUI or HTA interface
around that functionality. (See the MSI code page for
the script-based unpackers, the MBase MSI Editor and other MSI scripts.)
Download jsmsi.zip (206 KB)
Back to Index
The Snazzy Line of Components
The Snazzy components are for people interested in "skinning" or
customizing the graphic display of a component interface. At this time
there is only one Snazzy version, the Progress Bar (JSProgBr2). JSProgBr2
is functionally the same as the normal progress bar but adds a number of
display properties.
Snazzy Progress Bar
Back to Index
Information
About Using Classes
Many of the scripts here use classes. This section is provided for people
who may not be familiar with the use of classes in VBScript. (Though it is not
necessary to understand classes in order to use them.)
A class is a programming expedient that provides a way to package code as an independent
unit for re-use. It is a self-contained unit that can be treated as an object. All you need to create a class
is this:
Class ClassName
'-- class code goes here.
End Class
Everything between Class [class name] and End Class is internal to the
class object. All methods or variables declared in a class as Private have a "scope", or visibility,
that does not extend outside the class. For example, you could declare the private variable "Object1" inside the class
and use it to create an instance of the FileSystemObject. That variable, and the FSO instance, will not be
visible outside of the class. The self-contained aspect of classes means that you can design a class as
a custom object, choosing properties and methods to make visible by declaring them as Public, while the
functionality behind those properties and methods is hidden inside the class.
Since only the properties and methods of a class declared as Public are visible from outside the
class, a class can be pasted into any number of scripts without having any effect on the operation of
those scripts. It's like being able to paste the FileSystemObject into your script: Whether you use the object
or not, it does not affect your script code because only the Public methods and properties are
visible to the rest of the script. (Note, though, that public variables declared outside the class, in
the same script, are visible from inside the class, so it's a good idea to use unique variable
names inside script classes.)
Many of the scripts available here use classes in order to neatly package functionality.
You can use those classes by pasting them into your scripts and calling the public methods.
You do not necessarily need to understand the code inside a class that you use, any more than you
need to understand how the FileSystemObject works, although with VBScript classes you can also
change the code and the public methods of the class.
See the Class Demo and Class Block Demo samples (above) for more
information about writing classes.
Back to Index
Tutorial: Using HTAs (HTML Applications)
A number of the downloads here are in the form of HTAs. Some of the JSWare utilities (Such as the MSI editor and XPFix tools) are also HTAs.
This tutorial is here to provide a basic explanation and guid to using HTAs. HTAs are easy to use and there is not much to know, but there has been a
great deal of misinformation concerning HTAs, unnecessarily making them seem exotic and abstruse.
For all practical purposes, an HTA is just a webpage running in Internet Explorer, but with virtually
no security restrictions. For some reason many people have got the idea that an HTA is a special kind
of software program that is not running in a browser. That is not true. Microsoft's
own webpage refers to HTAs as IE webpages.
If you rename an HTML file with a ".hta" extension then it's an HTA. Simple as that.
A bit of history
Internet Explorer has long been used to
create interactive, highly functional, webpage utilities using HTML, CSS and script. Microsoft
provided vast document object model functionality, as well as support for ActiveX. Unfortunately,
that functionality has rendered IE all but unusable online. Internet Explorer is so closely tied into
Windows, and provides so many ways to run executable code, that it is not safe to use on the
Internet. With Internet Explorer 5 Microsoft began an effort to deal with that problem. They created
the HTA -- which is little more than a method to turn off IE security restrictions -- while gradually
increasing Internet Explorer security for normal webpages. That strategy allowed people to continue
using IE to create script-based GUI programs by switching the file extensions from ."html" to ".hta".
Over time, Internet Explorer security has become an increasingly unworkable morass: not sufficient
online and too restrictive offline. But HTAs continue to provide an easy, handy way to harness the
extensive functionality of IE scripting.
The difference between HTA and HTML
As noted above, if you rename an HTML file to HTA then you've got an HTA. That's all it takes.
There are some minor details worth learning about, but in general there is nothing new that you have
to learn. HTML, CSS and script work in an HTA just as they do in an HTML file loaded into Internet Explorer.
Security: The big difference with HTAs is security. The one and only security restriction is that an HTA must run locally.
If you click a link to an HTA online with IE you will get a download prompt. Aside from that, all of your code
should work. You can use FileSystemObject, "unsafe" ActiveX controls, etc.
Structure: Behind the scenes, an HTA file is actually loaded by a program named MSHTA.exe, rather
than IEXPLORE.exe. MSHTA provides the parent window frame or "chrome". If you look at the window
hierarchy under an instance of Internet Explorer vs an open HTA, you will see that all open webpages are
displayed in a window with the class name "Internet Explorer_Server". That's the actual browser window.
It's the essence of IE and of HTAs. But running the browser window through MSHTA
provides a few extra options that do not exist with IE. An HTA window frame does not have the IE menu, toolbar and icons.
Also, HTAs have a custom HTML tag that is read by MSHTA when the file is loaded. That tag is <HTA:APPLICATION>.
Using the <HTA:APPLICATION> tag
<HTA:APPLICATION> is not required to turn a webpage into an HTA. Only the file
extension change is required. But the <HTA:APPLICATION> tag is actually very useful. The tag goes in the HEAD tag, and according to Microsoft
it is supposed to have a closing tag, like so: <HTA:APPLICATION> </HTA:APPLICATION>.
That doesn't make sense, since the tag has no content, but it doesn't really matter, because it works fine either way - with or without the closing tag.
The <HTA:APPLICATION> tag provides several attributes, which have corresponding
script properties. (The properties have typical script property usage. Use an ID attribute for the tag like so:
<HTA:APPLICATION ID="HTA"> </HTA:APPLICATION>
in order to access the attributes at runtime. But note that the properties are generally read-only, so they're of little value.)
<HTA:APPLICATION> Attributes
The HTA attributes are listed below. Where there are a limited number of possible values, the default value is shown in bold.
ID: ID is a standard HTML attribute. It's mentioned only because it's needed to access the properties.
APPLICATIONNAME: This is an unusal attribute. An HTA title bar displays the content of the TITLE
tag, just like a normal webpage. APPLICATIONNAME is used for something else: If a value is provided for APPLICATIONNAME then
the class name of the HTA parent window will actually be changed to conform to that name. All windows in Windows have what is
known as a class name, which indicates the type of window. Normally an HTA parent window
has the class name HTML Application Host Window Class But if you use <HTA:APPLICATION APPLICATIONNAME="OkeyDokey">
then the parent window class name will become "OkeyDokey"! Windows uses this attribute with the SINGLEINSTANCE attribute. If SINGLEINSTANCE is
set to "yes" the window class name helps to check for an already-running instance among the collection of open windows. There seems to be no other purpose to this attribute.
BORDER: thick, dialog, thin, none
BORDERSTYLE: normal, raised, sunken, complex (raised/sunken combo), static
CAPTION: yes, no. Despite the name, this property does not provide a title bar caption.
(The TITLE attribute does that.) CAPTION controls whether the title bar is present at all.
CONTEXTMENU: yes, no. (Is the context menu functional?)
ICON: Path to 32x32 icon file to display on title bar.
INNERBORDER: yes, no. (Inner window border displayed? This property doesn't seem to work.)
MAXIMIZEBUTTON: yes, no. (Show max. button in control box on titlebar?)
MINIMIZEBUTTON: yes, no. (Show min. button in control box on titlebar?)
NAVIGABLE: no, yes. (Load links in same window? no, the default, is equivalent to TARGET="_blank", opening links in a new window.)
SCROLL: yes, no, auto. (Are scrollbars displayed?)
SCROLLFLAT: no, yes. (Are scrollbars shown flat? This property doesn't seem to work. Perhaps it requires XP styles.)
SELECTION: yes, no. (Can page content be selected for copying, etc.?)
SHOWINTASKBAR: yes, no.
SINGLEINSTANCE: no, yes
SYSMENU: yes, no. (Controls whether that useless little "system menu" appears when clicking on the program icon at far left of titlebar.)
VERSION: Optional version number.
WINDOWSTATE: normal, maximize, minimize
Getting App Path and Command Line in an HTA
To get the parent folder path of the currently running HTA you can use a short function
to clean up the window.location string, just as might be used in HTML:
Function GetHomePath()
Dim sHome, LPt
GetHomePath = window.location
GetHomePath = Replace(GetHomePath, "/", "\")
LPt = InStrRev(GetHomePath, "\\")
If LPt > 0 Then GetHomePath= Right(GetHomePath, (len(GetHomePath) - (LPt + 1)))
GetHomePath= Replace(GetHomePath, "%20", " ")
LPt = InStrRev(GetHomePath, "\")
GetHomePath = Left(GetHomePath, LPt)
End Function
With HTAs there is also a property of the <HTA:APPLICATION> element known as
commandLine, which is accessed by using an ID attribute in the
<HTA:APPLICATION> tag.
Ex.:
<HTA:APPLICATION ID="HTA">
s = HTA.commandLine
Unfortunately, this leaves much to be desired. First, an HTA has no facility for drag-drop in its
window. So while it's possible to get the path of a file dropped onto the HTA file in order to run it, there is
no way to get the paths of files dropped onto the HTA window itself. And since an HTA is a GUI program,
the startup commandline is of limited usefulness. In addition, commandLine returns a rather odd string.
It does not contain the actual command line. Rather, it returns
the HTA file path plus the command line! It's formatted as though it were a shell command line used to run the HTA. It's also confusing in that
quotes are unpredictable. The HTA path seems to be sent in quotes even when there are no spaces in the path. Yet the path of
a dropped file is only in quotes if the path has spaces. So, if you find that you have any use for this commandLine property at
all then you'll need to clean it up after retrieving it:
<HTML><HEAD>
<HTA:APPLICATION ID="HTA">
<SCRIPT LANGUAGE="VBScript">
Dim HTAPath, sCommand
Sub window_onload()
Dim s, Pt1, iQ, i2, Q2
s = HTA.commandLine
Q2 = Chr(34)
iQ = 0
For i2 = 1 to Len(s)
Select Case Mid(s, i2, 1)
Case " "
If iQ Mod 2 = 0 Then
HTAPath = Left(s, i2 - 1)
HTAPath = Trim(Replace(HTAPath, Q2, ""))
If Len(s) > i2 Then
sCommand = Right(s, Len(s) - i2)
sCommand = Trim(Replace(sCommand, Q2, ""))
End If
Exit For
End If
Case Q2
iQ = iQ + 1
Case Else
'-
End Select
Next
End Sub
</SCRIPT>
</HEAD>
IMPORTANT: A complex HTA may cause problems in IE whereby Windows insists on ending the execution of HTA script. See the next topic for explanation.
Back to Index
Problems with Internet Explorer
The Wacky Script Timeout Bug: There is a bug with Internet Explorer, at least since IE 5.5. When a long
operation runs in an HTA. You may see a message like the following:
"A script on this page is causing Internet Explorer to run slowly. If it continues to run, your
computer may become unresponsive. Do you want to abort the script?"
That message seems like a good idea. It provides a way to end a script that runs far longer
than anticipated. But sometimes script in an HTA needs to run for several minutes, and once the timeout message
appears it won't go away. Even if you dismiss the message, it just pops back up. The result is not an option
to end a long script. One is forced to stop the script in order to end the inane message boxes!
Microsoft does not seem to acknowledge this bug, but they do provide a webpage that
offers help: http://support.microsoft.com/kb/175500
That page explains a Registry setting that can be used to eliminate the timeout warning messages. If you would like
a pre-written script to make that setting, click here to download IETOFix.zip.
Back to Index
Problems Specific to Internet Explorer 7 and 8
There are likely to be problems with some of the JSWare scripts if you install Internet Explorer 7 or 8.
For example, the custom message box may no longer work properly. (It will no longer be possible to display
a sized IE window in FullScreen [borderless] mode.) Some, or all, of the webpage utilities
are also likely to malfunction, especially in terms of display and possibly in terms of script security issues or
rendering problems.
The reason for problems: IE7 made a number of changes in security settings, CSS rendering, and the
IE Document Object Model.
Solutions? - The best solution to problems with IE7/8 compatibility is simply not to install them in the
first place. IE7/8 are not really browser updates, anyway. They will only install on Windows XP SP2 and Vista.
If you do not want IE7 forced upon you through XP Automatic Updates,
create the following DWORD Registry entry to block IE7 installation:
Key: HKLM\SOFTWARE\Microsoft\Internet Explorer\Setup\7.0\
Value Name: DoNotAllowIE70
Data: 1
The method to block IE8 is the same. Just substitue "8" for "7" in the above key and value names.
Back to Index
Vista Schmista - About Support for Various Windows Versions
In general, all of the scripts and components here should work on all versions
of Windows, from Windows 95 through XP. (On Windows 95/98/NT4 the Windows Script
Host may need to be installed.) The components have been specifically designed to use
only Win32 API functionality that work on Win95.
Scripts on Windows Vista/7:
Most of the scripts here have not been tested at all on Windows Vista/7. In general, if you want scripts
to work properly on Vista/7 you need to give yourself permission. The default status when installing
Vista/7 is something that might be referred to as a "fake Administrator". Basically Microsoft renamed
the "power user" permission level to Administrator, thereby creating two permission levels called
Administrator and causing a great deal of confusion. The fake Administrator has limited rights but
can "elevate" to Administrator in some cases. However, there are severe limitations with that approach.
For instance, there is no context menu item to run an HTA elevated. Likewise with running
drag-drop scripts. It is unclear why anyone would want to run in fake Administrator mode, as Microsoft
recommends. The partial security advantage is matched with partial functionality and endless nags --
the worst of both worlds. If you do want to run as the "real" Administrator you can give
Administrator status to your normal fake Administrator account by entering the following in the Run window
and then rebooting:
Net user administrator activate:yes
To reverse the change, enter "no" instead of "yes". If your fake Administrator account has a password you may need
to run this command from an elevated cmd.exe window so that you
can first enter your password:
Net user administrator [password]
Net user administrator activate:yes
Components on Windows Vista/7:
The components here are designed not to run
on Windows Vista/7. (Since Windows 7 is just a minor update to Vista, the two products are treated here as one.) At JSWare we do not consider Vista/7 to be a usable product, given the bloat, restrictions, spyware, etc.
We therefore do not
want to waste time testing on and adapting to Vista/7. Also, since these components
are all free to the public, we are unwilling to deal with the increased support requests
that would likely result in the face of Vista/7's problems with backward compatibility,
bizarre security issues, etc. If you manage to use any JSWare components on Vista/7 then you are on your own. Please do
not write to JSWare with support questions. Our full "Vista/7 response" is
here, for anyone who may be interested.
Back to Index
License Information
This license supersedes any older license that may be included with
scripts and components from JSWare.
You use all script code and components from JSWare at your own risk.
The components (compiled DLL and EXE files) may be used for personal or
commercial purposes. No payment or attribution is required for either use.
The components may be redistributed if they are required as support files
for scripts or software that you have written.
Also, the script code may be used freely, in part or as whole scripts,
for any purpose, personal or commercial, without payment or attribution.
I ask only that you not redistribute these scripts and components, except
as required for your direct use. Instead, please direct others to obtain copies
of JSWare scripts and components directly from www.jsware.net.
Also, none of the code here may be redistributed under another license. If a
work using code from JSWare is distributed with restrictions of any kind
the code from JSWare must be kept exempt from those restrictions.
This includes, but is not limited to, code sold for profit, code with usage restrictions
and code distributed as so-called "Open Source" with redistribution restrictions.
Back to Index
|