Skip to main content

Overview

VBScript utilities for Windows system automation and configuration. These scripts are tested on Windows 7, 10, and 11 (x64).
VBScript is a legacy scripting language still supported in modern Windows for backward compatibility. For new projects, consider using PowerShell instead.

Prerequisites

  • Windows 7, 10, or 11 (x64)
  • Administrator privileges (for most operations)
  • Windows Script Host (WSH) enabled (enabled by default)

Available Scripts

Autorun Disable

Disable Windows AutoRun/AutoPlay functionality to enhance security. Download:
Usage:
  1. Download the script
  2. Right-click autorun.vbs
  3. Select “Open with” → “Microsoft Windows Based Script Host”
Or simply double-click the file.
Features:
  • Disables AutoRun for all drives
  • Disables AutoPlay for removable media
  • Registry-based configuration
  • Improves security against USB-based attacks
  • Prevents automatic execution of malware
What It Does:
Prevents automatic execution of programs when removable media (USB drives, CDs, DVDs) is inserted.Protection Against:
  • USB-based malware
  • Auto-executing viruses
  • Unwanted program launches
  • Social engineering attacks
The script modifies the following registry keys:
Sets:
  • NoDriveTypeAutoRun = 255 (disable all drive types)
  • NoAutorun = 1 (disable autorun)
Disables AutoRun/AutoPlay for:
  • USB flash drives
  • External hard drives
  • CD/DVD drives
  • Memory cards
  • Network drives

Script Details

How VBScript Works on Windows

VBScript files (.vbs) are executed by Windows Script Host (WSH), which provides two execution environments:
  • wscript.exe: GUI mode (default when double-clicking)
  • cscript.exe: Console mode (for command-line usage)

Execution Methods

Security Considerations

Important Security Notes:
  1. Review Before Execution: Always review VBScript content before running
  2. Administrator Rights: Most system modifications require admin privileges
  3. Backup Registry: Create a registry backup before running system modification scripts
  4. Test Environment: Test scripts in a non-production environment first

Why Disable AutoRun?

AutoRun/AutoPlay was a common attack vector:
  • Malware Propagation: Infected USB drives could auto-execute malware
  • Social Engineering: Attackers could disguise malware as legitimate autorun content
  • Worm Spreading: Network worms used AutoRun to spread across systems
Microsoft has disabled AutoRun by default in Windows 7 and later for removable drives, but AutoPlay may still be enabled. This script ensures both are disabled.

Advanced Usage

Running at System Startup

Verifying AutoRun Status

Check if AutoRun is disabled:
Expected output:

Reverting Changes

To re-enable AutoRun (not recommended):

Alternatives to VBScript

For modern Windows automation, consider:

PowerShell

Modern, powerful scripting language built into Windows

Batch Scripts

Simple command-line scripts for basic automation

Troubleshooting

Possible Causes:
  • Windows Script Host disabled
  • Antivirus blocking execution
  • File association broken
Solutions:
Solution:
  • Run Command Prompt as Administrator
  • Use elevated privileges
Solution:
  • Log off and log back in
  • Restart Windows Explorer
  • Reboot the system

Best Practices

  1. Code Review: Always review VBScript contents before execution
  2. Backup: Create system restore point before running system modification scripts
  3. Testing: Test scripts in virtual machines or test environments first
  4. Documentation: Keep notes of what scripts do and when they were run
  5. Updates: Check for script updates periodically

Additional Resources

Windows Script Host

Learn more about WSH and VBScript fundamentals

Registry Editor

Understanding Windows Registry for advanced configuration

Security Hardening

Windows security best practices and hardening guides

PowerShell Migration

Migrate from VBScript to modern PowerShell scripts

License

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND. Test scripts in a safe environment before deploying to production systems.