VBScript Scripting Techniques
This section is dedicated to VBScript scripting techniques, how-tos,
and "code snippets" for your "snippets library".
Not many complete ready-to-run script samples here, but demo scripts,
and code snippets that can be used to "glue" together your own full-blown
scripts.
I intend to gradually expand this library of VBScript snippets.
Data & Variables
Databases
Working with Files
Working with Folders
Internet
Inventory
MultiMedia
Network
Object Browsers
OLE Automation
Printing
Processes & Services
Registry
Regular Expressions
Shortcuts
Time & Date
User Interaction
Data & Variables
Arrays, ArrayLists, SortedLists & Dictionary Objects
Array
Sort
Display
Reverse
ArrayList
SortedList
Dictionary
(also known as "associative array")
Integers
Integer Divide methods
Random Numbers
Standard VBScript
.NET Framework
True Random Numbers (Functions)
True Random Numbers (Class)
True Random Numbers (WSC )
Roman Numerals
Convert decimal numbers to Roman numerals
Convert Roman numerals to decimal numbers
Strings
Pad Strings
Back to the top of this page . . .
Databases & Spreadsheets
Read MS-Access databases
(without using MS-Access)
Read Excel files
(without using Excel)
XML Files
Back to the top of this page . . .
Working with Files
CAB Files
MakeCab
Extract CAB files with System.Shell Folders' CopyHere method
INI Files
ReadINI
WriteINI
DeleteINI
Sample Script
MD5 Checksums
X-MD5
Encode or Encrypt Files
X-Base64
XOR
Self-Destruct
Self-Destruct by Denis St-Pierre
XML Files
XMLDOM
ZIP Files
ZIP files and/or folders with X-ZIP
ZIP folders with System.Shell Folders' CopyHere method
UNZIP with X-ZIP
UNZIP with System.Shell Folders' CopyHere method
Back to the top of this page . . .
Working with Folders
Create multi-level folders like CMD.EXE's MD does
Cruto Creations' list of
special
folders and the VBScript code to get their paths and list their contents
Delete folders, empty or not, like DOS' DELTREE does
Back to the top of this page . . .
Internet
Download Files using HTTP
WinHTTP
X-HTTP
Upload & Download Files using FTP
ChilkatFTP
Send e-Mail Messages
CDOSYS
Query freedb.org CD Database
FREEDBControl.uFREEDB
Query WhoIs Database
InternetExplorer.Application (Function)
InternetExplorer.Application (Class)
InternetExplorer.Application (WSC )
Query Yahoo Financial Pages for Currency Exchange Rates
WinHTTP (Function)
WinHTTP (Class)
True Random Numbers
(use WinHTTP to retrieve true random integers from
random.org )
RndInt (function to retrieve a single random integer)
RndIntArr (function to retrieve multiple random integers)
Random (class to retrieve multiple random integers)
Random.wsc (component to retrieve multiple random integers)
Check if Websites are Up-And-Running
WinHTTP
X-HTTP
Back to the top of this page . . .
Inventory
Check if a computer is a laptop
Win32_Battery
Generate an MSInfo report
Msinfo32.MSInfo.1
Back to the top of this page . . .
Query freedb.org CD Database
FREEDBControl.uFREEDB
Back to the top of this page . . .
Network
Ping Computers
Win32_PingStatus
Retrieve Names
User Name
Environment Variable
WshNetwork
ADSI (WinNTSystemInfo)
ADSI (ADSystemInfo)
WMI (Win32_ComputerSystem)
Computer Name
Environment Variable
WshNetwork
SHGINA.DLL (Shell.LocalMachine)
ADSI (WinNTSystemInfo)
ADSI (ADSystemInfo)
WMI (Win32_ComputerSystem)
Computer Domain or Workgroup Name
WMI (Win32_ComputerSystem)
WMI (Win32_NTDomain)
User Domain Name
Environment Variable
WshNetwork
ADSI (WinNTSystemInfo)
ADSI (ADSystemInfo)
Wake Up Computers
UltraWOL
Back to the top of this page . . .
Object Browsers
Editors, IDEs & Object Browsers
Back to the top of this page . . .
OLE Automation
Automate MS Word
SaveAs : convert MS Word documents to HTML
SaveAs : convert MS Word documents to PDF
SaveAs : convert MS Word documents to RTF
SaveAs : convert MS Word documents to XPS
CapsLock : use MS Word (or WordPerfect) to check the CapsLock status
More MS Office automation scripts at the Microsoft Technet ScriptCenter
Office
Space Archive
Automate WordPerfect
PublishPDF : convert WP documents to PDF
SaveAs : convert WP documents to HTML
Type : type and format text
CapsLock : use WordPerfect (or MS Word) to check the CapsLock status
An introduction to
Automating
OpenOffice.org
Automate burning CDROMs and DVDs with
IMAPI
(lots of working sample scripts)
Automate SnagIt screen captures
Back to the top of this page . . .
Printing
Print Files
Shell.Application
Back to the top of this page . . .
Processes & Services
Processes
Kill Processes by Denis St-Pierre
Services
Restart Services
Back to the top of this page . . .
Registry
WMI StdRegProv
More information on the
StdRegProv
and
WMI
Registry functionality is available on MSDN
Back to the top of this page . . .
Regular Expressions
Regular Expressions in VBScript
The RegExp object
Patterns
Examples
Back to the top of this page . . .
Shortcuts
Shortcuts
GetShortcut by Denis St-Pierre
Back to the top of this page . . .
Time & Date
Delays
Back to the top of this page . . .
User Interaction
Browse Folder Dialog
Shell.Application
Change Default Printer Dialog
MSComDlg.CommonDialog.1
Change Password Dialog
InternetExplorer.Application
File Open Dialog
UserAccounts.CommonDialog
SAFRCFileDlg.FileOpen
File Save Dialog
SAFRCFileDlg.FileSave
Login Dialog
InternetExplorer.Application
Prompt for Passwords
ScriptPW.Password
InternetExplorer.Application
Progress Bars
Copy Folders with Progress Bar using System.Shell Folders' CopyHere method
Prompt for User Input
WSH (StdIn or InputBox)
InternetExplorer.Application
Back to the top of this page . . .