Script Runtime
What it is
The script runtime
(cscript.exe or wscript.exe) hold two additional objects that will help
in making your scripts do what you want them to, the Dictionary object
and the FileSystemObject object. Here I'll also explain the Script
Encoder which can be used to "obfuscate" a script.
What it provides
The Script Runtime makes the following objects available:
Dictionary
The Dictionary object is sort of an Array on steroids. With an Array
you can store data in a sequence but it is up to you to know what data
is in what position in the Array. The Dictionary object on the other
hand stores data in key & value pairs. So, instead of referring to
the data by its index number the way you would in an array:
arrCapitals (1) = "Helsinki"
...you reference it by its associated key:
dictCapitals("Finland") = "Helsinki"
The Dictionary object can even tell you what keys exist (so you don't have to guess) with its Keys method.
Provides:
Properties: Item, Count, CompareMode, etc.
Methods: Add, Keys, Exists, etc.
FileSystemObject
The FileSystemObject object gives, as the name implies, access to the
Filesystem. Through its objects you get the ability to handle files,
folders and disks.
Provides:
Properties: Drives.
Methods: GetFolder, CreateTextFile, CopyFile, etc.
Objects: Drive, File, Folder, TextStream.
The additional objects FileSystemObject provides:
Drive:
Properties: FreeSpace, VolumeName, FileSystem, etc.
Methods: None.
File:
Properties: Attributes, DateLastModified, Name, etc.
Methods: Copy, Delete, CreateTextFile, etc.
Folder:
Properties: DateLastAccessed, Files, Size, etc.
Methods: Copy, Delete, CreateTestFile, etc.
TextStream:
Properties: AtEndOfLine, Column, Line, etc.
Methods: Close, ReadLine, Write, etc.
Script Encoder
Verbatim from MSDN:
With this tool it is possible to encode a script in order to make it more difficult for an end user to see how the script is written. If you for example don't want any end users who find their way to %logonserver%\netlogon to be able to be able to simply open up any script in their favorite editor and directly see what's going on during login you could encode them. Encoded scripts will execute exactly like regular scripts.
A regular script might look like this:
Dim intTest
intTest = 5
WScript.Echo "intTest: " & intTest + 1
Running it through the Script Encoder would produce a script that look like this:
An encoded VBScript script would get the extension .vbe.
Please remember though that this is NOT the same as encrypting a script. There are plenty of decryption tools available on the Internet for anyone who is bent on reading your code. This is only what is called "obfuscation", making it a little harder to get at the code.
