VBScript Tutorial for Beginners: Learn VBScript for Windows Automation

By Softlookup Editorial Team · Updated April 25, 2026 · 18 min read · Free 21-chapter course

Honest framing: VBScript was originally designed for browser scripting in Internet Explorer — that use case is completely dead. But VBScript is still very much alive for Windows Script Host (WSH) automation, Classic ASP web apps, QTP/UFT test scripts, and maintaining the millions of .vbs files still running in banks, insurance companies, and government systems. This tutorial focuses on those uses.
21
free chapters
15 hrs
total study time
$0
cost (built into Windows)
30+ yrs
VBScript history (1996+)

What Is VBScript?

VBScript (Microsoft Visual Basic Scripting Edition) is a scripting language created by Microsoft in 1996, modeled on the Visual Basic syntax. It runs through the Windows Script Host (WSH) — a built-in Windows component that executes scripts without compilation.

You write VBScript in a plain text file, save it with a .vbs extension, and Windows runs it. No compiler, no IDE required, no install. That simplicity is why VBScript became the standard automation tool for Windows administrators throughout the 2000s and is still common today.

Where VBScript Is Still Used in 2026

If you're learning VBScript today, it's almost certainly because of one of these:

Use CaseWhat It Looks LikeWhy VBScript
Windows Script HostSystem administration scripts, scheduled tasksBuilt into every Windows since 98, no install
Classic ASPLegacy .asp web pages on IIS serversMany enterprise applications never migrated
QTP / UFT testingAutomated UI test scriptsOpenText UFT One uses VBScript as its scripting engine
SCCM / MDT scriptsWindows deployment automationDecades of existing infrastructure
Excel automation (legacy)Office spreadsheet macros (older)Cross-document scripts via WSH
Where VBScript is dead: Browser-based scripting in HTML pages. Internet Explorer was retired in 2022, and no modern browser ever supported VBScript. If you find a tutorial telling you to embed <script language="vbscript"> in a webpage, it's outdated — that won't run in Chrome, Firefox, Safari, or Edge.

Should You Learn VBScript or PowerShell?

Quick answer: PowerShell for anything new, VBScript only for maintenance. PowerShell is more powerful, better supported, and Microsoft's recommended path forward.

But there are real reasons to learn VBScript anyway:

  1. Legacy code maintenance. Millions of .vbs files run production systems. Someone has to maintain them. That someone is well-paid because the talent pool is shrinking.
  2. Classic ASP support. Some banks, government systems, and ERP applications still run on Classic ASP. They can't migrate easily and need VBScript developers.
  3. QTP/UFT tests. If you're in QA at an enterprise, your test framework is probably UFT, and UFT scripts are written in VBScript.
  4. Restricted environments. Some corporate environments disable PowerShell via group policy but allow Windows Script Host. VBScript still works there.

Microsoft Is Phasing VBScript Out

In May 2024, Microsoft announced VBScript will become a Features on Demand (FoD) component, then eventually be removed from Windows entirely. The timeline so far:

This makes VBScript skills both more valuable (legacy migrations need experts) and less worth specializing in (long-term outlook is decline). The sweet spot: learn enough VBScript to maintain existing code and help with PowerShell migrations.

Prerequisites

None. You don't need programming experience. You don't need any installs (if you're on Windows). You just need a text editor — Notepad works, but VS Code or Notepad++ is better.

Your First VBScript

Open Notepad. Type this:

MsgBox "Hello, VBScript!"

Save as hello.vbs on your Desktop. Make sure to:

Double-click the file. A message box pops up. That's it — you've run VBScript.

Two Ways to Run VBScript

Windows ships with two VBScript engines:

EngineOutputBest For
wscript.exeGUI dialogs (default)End-user scripts, Windows shortcuts, scheduled tasks
cscript.exeConsole outputAdmin scripts, batch files, command-line use

Run a script in console mode:

cscript hello.vbs

To set cscript as the default for all .vbs files:

cscript //h:cscript //s

VBScript Variables

VBScript is loosely typed — every variable is a Variant that can hold any data type.

Dim name, age, salary
name = "Alice"
age = 30
salary = 55000.50

MsgBox name & " is " & age & " years old"

The & operator concatenates strings. Use it instead of + for concatenation — + works on numbers but causes errors when mixing strings and numbers.

Best practice: Always start scripts with Option Explicit at the top. It forces you to declare every variable with Dim, catching typos before they become runtime bugs.
Option Explicit
Dim userName
userName = "Alice"
MsgBox userName

Control Flow: If, Select, Loops

If statements

Dim hour
hour = Hour(Now)

If hour < 12 Then
    MsgBox "Good morning"
ElseIf hour < 18 Then
    MsgBox "Good afternoon"
Else
    MsgBox "Good evening"
End If

Select Case (cleaner than long If chains)

Dim day
day = WeekDay(Now)

Select Case day
    Case 1: MsgBox "Sunday"
    Case 2: MsgBox "Monday"
    Case 3 To 5: MsgBox "Midweek"
    Case Else: MsgBox "Weekend"
End Select

For loops

Dim i
For i = 1 To 10
    WScript.Echo "Counter: " & i
Next

Do While / Do Until

Dim count
count = 0

Do While count < 5
    WScript.Echo count
    count = count + 1
Loop

Working with Files (The Real Reason to Learn VBScript)

This is where VBScript shines as a Windows admin tool. The FileSystemObject gives you full access to drives, folders, and files.

' Read every line of a text file
Dim fso, file, line

Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.OpenTextFile("C:\logs\error.log", 1)

Do Until file.AtEndOfStream
    line = file.ReadLine
    WScript.Echo line
Loop

file.Close

Other common file operations:

' Check if a file exists
If fso.FileExists("C:\data\config.ini") Then
    WScript.Echo "Found"
End If

' List every file in a folder
Dim folder, fileItem
Set folder = fso.GetFolder("C:\reports")

For Each fileItem In folder.Files
    WScript.Echo fileItem.Name & " - " & fileItem.Size & " bytes"
Next

' Copy a file
fso.CopyFile "C:\source\data.csv", "C:\backup\data.csv"

' Create a new file and write to it
Set file = fso.CreateTextFile("C:\output\result.txt", True)
file.WriteLine "Hello from VBScript"
file.Close

Running Programs and Commands

The WScript.Shell object lets you execute any program or command-line tool:

Dim shell
Set shell = CreateObject("WScript.Shell")

' Run Notepad
shell.Run "notepad.exe"

' Run a command and wait for it to finish
shell.Run "cmd /c dir C:\ > C:\filelist.txt", 0, True

' Read an environment variable
Dim userProfile
userProfile = shell.ExpandEnvironmentStrings("%USERPROFILE%")
WScript.Echo userProfile

VBScript and Classic ASP

Classic ASP (Active Server Pages) uses VBScript as its server-side scripting language. ASP pages have a .asp extension and run on Microsoft IIS web servers. The syntax is identical to standalone VBScript, just wrapped in <% %> tags:

<%
    Dim userName
    userName = Request.Form("username")

    If userName = "" Then
        Response.Write "Please log in"
    Else
        Response.Write "Welcome, " & userName
    End If
%>
Fun fact: The page you're reading right now is served by Classic ASP — every URL on softlookup.com that ends in .asp uses VBScript on the server.

Subroutines and Functions

Two ways to organize reusable code:

' Subroutine: does something, returns nothing
Sub Greet(person)
    MsgBox "Hello, " & person
End Sub

Greet "Alice"

' Function: returns a value
Function Multiply(a, b)
    Multiply = a * b
End Function

Dim result
result = Multiply(6, 7)
MsgBox result   ' Shows 42

Error Handling

VBScript's error handling is unusual — there's no try/catch. You enable error suppression with On Error Resume Next, then check Err.Number:

On Error Resume Next

Dim result
result = 10 / 0

If Err.Number <> 0 Then
    WScript.Echo "Error: " & Err.Description
    Err.Clear
End If

On Error GoTo 0   ' Disable error suppression

Common Beginner Mistakes

1. Saving with the wrong file extension

Notepad's "Save as" defaults to .txt. If you save your script as hello.vbs.txt, Windows treats it as a text file. Always change "Save as type" to "All Files" before saving.

2. Forgetting Set with object variables

Regular variables use =. Object variables require the Set keyword:

' Wrong:
fso = CreateObject("Scripting.FileSystemObject")

' Right:
Set fso = CreateObject("Scripting.FileSystemObject")

3. Using + for string concatenation

Use & instead. + works on numbers but produces errors when mixing types:

' Risky:
result = "Age: " + age

' Always safe:
result = "Age: " & age

4. Confusing = and Set in conditions

VBScript uses = for both assignment and comparison. If x = 5 Then compares; x = 5 on its own line assigns. The language figures out which by context.

5. Running an old browser-based VBScript example

If you find a tutorial example like <script language="vbscript"> in HTML, that's the dead use case. It runs in Internet Explorer (which doesn't exist anymore), not in Chrome/Firefox/Edge. Stick to .vbs and .asp files.

Complete Learning Path

Work through the 21 chapters below in order. Estimated time: 30–45 minutes per chapter.

Start Chapter 1: Introducing VBScript →

VBScript Cheat Sheet

TaskCode
Show a messageMsgBox "Hello"
Console outputWScript.Echo "Hello"
Get user inputname = InputBox("Your name?")
Concatenate stringsfull = first & " " & last
Current date/timenow = Now
Run a programCreateObject("WScript.Shell").Run "notepad.exe"
Read a fileSet f = fso.OpenTextFile("C:\file.txt", 1)
Write a fileSet f = fso.CreateTextFile("C:\out.txt", True)
File exists?If fso.FileExists("C:\file.txt") Then
Loop a folderFor Each f In fso.GetFolder("C:\").Files
Pause executionWScript.Sleep 1000 ' 1 second
Exit scriptWScript.Quit
Suppress errorsOn Error Resume Next
Check last errorIf Err.Number <> 0 Then ...

Frequently Asked Questions

Is VBScript still used in 2026?

Yes, in specific contexts. Browser-based VBScript is dead — no modern browser supports it. But VBScript is still actively used for Windows Script Host (WSH) automation, Classic ASP web applications, QTP/UFT test automation, and maintenance of legacy enterprise systems in banks, insurance, and government.

Should I learn VBScript or PowerShell?

PowerShell for new Windows automation projects — it's the modern, supported choice. VBScript only if you're maintaining existing .vbs scripts, working with Classic ASP, supporting QTP/UFT tests, or working in an environment that hasn't migrated yet. Many Windows admins know both.

Do I need to install anything to run VBScript?

No, if you're on Windows. The Windows Script Host (cscript.exe and wscript.exe) is built into every Windows version since Windows 98. Save your script as filename.vbs and double-click to run.

Is VBScript hard to learn?

VBScript is one of the easiest languages to learn. Syntax reads like English, there's no compilation, errors are forgiving, and you can run code immediately. Most people write working scripts within an hour.

What can VBScript do that PowerShell can't?

Almost nothing — PowerShell can do everything VBScript does and more. The exceptions are very specific legacy scenarios: maintaining Classic ASP code, working with QTP/UFT test scripts, or running on systems where PowerShell is restricted by group policy.

Will Microsoft remove VBScript from Windows?

Microsoft announced VBScript will become an on-demand feature in future Windows releases, eventually being removed entirely. The transition is gradual — VBScript still ships with current Windows versions, but Microsoft recommends migrating to PowerShell for new work.

Is VBScript the same as VBA?

No, but they're related. VBA (Visual Basic for Applications) runs inside Microsoft Office, with full access to those apps' object models. VBScript is a lighter version designed for scripting, missing some VBA features. Most code reads similarly between the two.

Do VBScript skills help me find a job?

Yes, in specific niches. Legacy maintenance roles at banks, insurance companies, and government agencies still require VBScript. Quality Assurance roles using QTP/UFT need it. Legacy specialist roles often pay above market because the talent pool is shrinking.

Start Chapter 1: Introducing VBScript →

Last updated: April 25, 2026.