Using the Chilkat ActiveX in VBScript

create Chilkat objects with CreateObject in .vbs scripts run by Windows Script Host

Windows · cscript.exe / wscript.exe, 32-bit or 64-bit · Chilkat ActiveX v11

The Chilkat ActiveX is a COM library, so a VBScript file can create Chilkat objects such as Chilkat.Http, Chilkat.JsonObject, or Chilkat.Crypt2 and call their methods. That gives a plain .vbs script HTTP/REST, email, FTP/SFTP, Zip, PDF, encryption, digital signatures, JSON, XML, and the rest of the Chilkat API, which makes it useful for scheduled jobs and administrative scripts. This page covers scripts run by Windows Script Host; for VBScript in web pages, see Chilkat in Classic ASP.

The 60-second version

  1. On 64-bit Windows, .vbs files run as 64-bit by default. Install the 64-bit Chilkat ActiveX (or both, if some scripts run as 32-bit).
  2. Save the first script as hello.vbs.
  3. Run it from a command prompt: cscript //nologo hello.vbs

On this page: Bitness Install First script JSON to CSV VBScript tips Scheduled tasks VBScript's future Troubleshooting

Setup

1

Know which script host runs your script

The Chilkat ActiveX DLL must have the same bitness as the process that runs the script. On 64-bit Windows there are two copies of each script host:

Script hostBitnessChilkat ActiveX needed
C:\Windows\System32\cscript.exe and wscript.exe
(the default: double-clicking a .vbs file, or typing cscript)
64-bit64-bit
C:\Windows\SysWOW64\cscript.exe and wscript.exe32-bit32-bit

A script can also be started by another program (a 32-bit application, a job scheduler, an installer). It then runs with whichever host that program starts. Installing both the 32-bit and 64-bit Chilkat ActiveX covers every case; they coexist without problems. To see which one a script is using, add this line:

WScript.Echo CreateObject("WScript.Shell").ExpandEnvironmentStrings("%PROCESSOR_ARCHITECTURE%")
' x86 = 32-bit script host, AMD64 = 64-bit
2

Install the Chilkat ActiveX

The MSI installers copy the DLL and register it, which is all VBScript needs:

v11.6.1 • 08-Sep-2026 • sha256: 23a6a3b9e18f7dd44753c1e4d4f0e170cf0807494be56e4385e69d529a694136
Chilkat 64-bit Per-Machine ActiveX MSI Installer

v11.6.1 • 08-Sep-2026 • sha256: 49402b7f5dfe0b39ee28fede63963bbc826c65693737f490c53afffa2c4bbbc5
Chilkat 32-bit Per-Machine ActiveX MSI Installer

v11.6.1 • 08-Sep-2026 • sha256: 8a38c7da817f640c7e34c3fe74a108c577f952e3a9141cbf179e129b2958ff4e
Chilkat 64-bit Per-User ActiveX MSI Installer

v11.6.1 • 08-Sep-2026 • sha256: 429f0e944f68780c9ba406202d9b8f35ab7f41d57c3528dcac244db24fb4eb0e
Chilkat 32-bit Per-User ActiveX MSI Installer

InstallerUse it when
Per-machineThe script runs as a scheduled task, as a service account, as administrator, or under more than one Windows account. Requires administrator rights to install.
Per-userOnly you run the script, from your own desktop session without elevation. Normally needs no administrator rights.

The ActiveX download page also has ZIP downloads with a register.bat script that registers the DLL with regsvr32. Keep the DLL on a local drive, not a network share. The downloads are the full version and are fully functional for a 30-day evaluation.

Examples

Your first script: unlock Chilkat and fetch a URL

Each script run is a new process, so each script calls UnlockBundle once at the start. During the 30-day trial any string works; after purchase, use your license code. Save this as hello.vbs:

Option Explicit
Dim glob, http, s

Set glob = CreateObject("Chilkat.Global")
If glob.UnlockBundle("Anything for 30-day trial") <> 1 Then
    WScript.Echo glob.LastErrorText
    WScript.Quit 1
End If

Set http = CreateObject("Chilkat.Http")
s = http.QuickGetStr("https://www.chilkatsoft.com/helloworld.txt")
If http.LastMethodSuccess <> 1 Then
    WScript.Echo http.LastErrorText
    WScript.Quit 1
End If

WScript.Echo s

Run it with cscript //nologo hello.vbs. The console shows Hello World!. (With wscript, or by double-clicking the file, WScript.Echo shows a message box instead.) The ProgID is Chilkat. plus the class name, for example Chilkat.JsonObject or Chilkat.Crypt2.

Download JSON and write a CSV file

This script downloads a small JSON document, parses it with Chilkat.JsonObject, and writes each member to a line of a CSV file. The same pattern works for any REST API: send the request with Chilkat.Http or Chilkat.Rest, then read the fields with StringOf, IntOf, and SizeOfArray.

Option Explicit
Dim glob, http, json, sb, jsonText, i

Set glob = CreateObject("Chilkat.Global")
If glob.UnlockBundle("Anything for 30-day trial") <> 1 Then
    WScript.Echo glob.LastErrorText
    WScript.Quit 1
End If

' {"apple":"red", "lime":"green", "banana":"yellow", ...}
Set http = CreateObject("Chilkat.Http")
jsonText = http.QuickGetStr("https://www.chilkatsoft.com/exampledata/sample.json")
If http.LastMethodSuccess <> 1 Then
    WScript.Echo http.LastErrorText
    WScript.Quit 1
End If

Set json = CreateObject("Chilkat.JsonObject")
If json.Load(jsonText) <> 1 Then
    WScript.Echo json.LastErrorText
    WScript.Quit 1
End If

Set sb = CreateObject("Chilkat.StringBuilder")
sb.Append "fruit,color" & vbCrLf
For i = 0 To json.Size - 1
    sb.Append json.NameAt(i) & "," & json.StringAt(i) & vbCrLf
Next

' Write the file as UTF-8 without a BOM.
If sb.WriteFile("fruit.csv", "utf-8", 0) <> 1 Then
    WScript.Echo sb.LastErrorText
    WScript.Quit 1
End If
WScript.Echo "Wrote fruit.csv"

The relative path fruit.csv is resolved against the current directory, which for a scheduled task is often C:\Windows\System32. Use full paths in scripts that run unattended.

Things to know when calling Chilkat from VBScript

Chilkat returns 1 or 0, not VBScript's True/False. Chilkat ActiveX methods that report success, and properties such as LastMethodSuccess, return 1 for success and 0 for failure. VBScript's True is -1, so compare with 1:

  • Correct: If success <> 1 Then … or If success = 0 Then …
  • Wrong: If success = True Then is never true, because 1 is not -1.
  • Also wrong: If Not success Then treats success as a failure too, because Not 1 is -2, which is nonzero.
TopicWhat to do
ErrorsChilkat doesn't raise script errors for ordinary failures. Check the return value (or LastMethodSuccess for methods that return a string or object) and print LastErrorText, which explains exactly what went wrong.
Checking CreateObjectIf the Chilkat ActiveX isn't registered for this script host, CreateObject stops the script with an error. To handle that yourself, wrap the call: On Error Resume Next, Set http = CreateObject("Chilkat.Http"), then test Err.Number and turn error trapping off again with On Error GoTo 0.
Exit codesUse WScript.Quit 1 on failure so a scheduler or batch file can detect it through %ERRORLEVEL%.
Non-English textThe console window may not display characters outside its code page correctly, even when the string is correct. Write the text to a UTF-8 file (as above) to check it.
Binary dataVBScript handles byte arrays poorly. Keep binary data inside Chilkat by using Chilkat.BinData and the methods that load from and save to files, or work with Base64 or hex strings.
Async methodsMethods ending in Async return a Chilkat.Task. Start it with task.Run(), then poll task.Finished, calling task.SleepMs 100 between checks, if the script needs to do something else (such as enforce its own time limit) while the operation runs.
Chilkat v9.5 scriptsv11 ProgIDs are Chilkat.Http, Chilkat.Global, and so on. Older scripts use Chilkat_9_5_0.Http. Both versions can be installed side by side; see Chilkat ActiveX v11 and v9.5 on the same computer.

Running scripts as scheduled tasks

  • Install the Chilkat ActiveX with a per-machine installer. A task that runs as another account, or with highest privileges, doesn't see a per-user registration.
  • In Task Scheduler, set Program/script to C:\Windows\System32\cscript.exe (or the SysWOW64 copy for 32-bit) and Add arguments to //nologo "C:\Scripts\job.vbs". Using cscript keeps WScript.Echo from opening message boxes that nobody can close.
  • Use full paths for every file the script reads or writes, and make sure the task's account can reach them.
  • Redirect output to a log with a batch file (cscript //nologo job.vbs >> job.log 2>&1), or write a log with Chilkat's StringBuilder.

VBScript's future in Windows

Microsoft has deprecated VBScript. It is now a Windows feature on demand that is still enabled by default. Microsoft has said it will be disabled by default in a later phase (around 2026 or 2027) and removed in a future Windows release. If a computer reports that VBScript isn't available, you can reinstall it from Settings » System » Optional features while that remains supported.

For new scripts, consider PowerShell, which can use the same Chilkat ActiveX: $http = New-Object -ComObject Chilkat.Http. Chilkat's .NET assemblies are another option in PowerShell.

Troubleshooting

MessageCause and fix
ActiveX component can't create object: 'Chilkat.Http'
(800A01AD)
The Chilkat ActiveX isn't registered for this script host. Usually its bitness doesn't match (64-bit cscript with only the 32-bit ActiveX installed, or the reverse), or it's registered per-user and the script runs as another account or elevated. Install the matching per-machine MSI, and check the ProgID spelling.
Object doesn't support this property or method
(800A01B6)
The method or property name is misspelled, or the installed Chilkat version is older than the one the script was written for. Check the name in the reference documentation.
Can't find script engine "VBScript" for script The VBScript feature on demand has been removed or disabled on this computer. See VBScript's future in Windows.
The script works when you run it but fails as a scheduled task Per-user registration, a relative file path, or a 32-bit/64-bit difference between your test and the task. See Running scripts as scheduled tasks.
A Chilkat method returns 0 or an empty string The operation itself failed (a network error, a bad password, an invalid file path, and so on). Print LastErrorText; it names the cause.

Next Steps

Windows, VBScript, and PowerShell are trademarks of the Microsoft group of companies.