File format · .vbe
Windows Script Host Files (.VBS, .JS, .WSF) Explained and Repaired
What Windows Script Host files are, how VBS, JS, JSE, VBE and WSF scripts work, why they fail to run, and how damaged script files are recovered.
Windows Script Host (WSH) is Microsoft's built-in automation and administration scripting environment for Windows. It has shipped as a standard component since Windows 98 and Windows NT 4.0 Service Pack 4, and it remains present in modern Windows releases, though Microsoft has progressively restricted it in favor of newer tools. Where a batch file can only issue shell commands, a WSH script can use COM objects to touch the file system, registry, network, and applications. This article explains the file types WSH runs, why these files break or refuse to execute, and what recovery involves.
What Windows Script Host is and which files it runs
WSH is language-independent. It does not interpret scripts itself; it loads an Active Scripting engine for the language a file is written in and provides that engine with a set of services and objects. By default, Windows ships with two engines: VBScript and JScript, Microsoft's JavaScript dialect.
The default file associations are:
- .VBS: plain-text VBScript
- .VBE: VBScript encoded with Microsoft's Script Encoder, so the source is not human-readable
- .JS: plain-text JScript
- .JSE: encoded JScript
- .WSF: Windows Script File, an XML-based container that can hold multiple jobs and mix languages in one file
- .WSH: a small text file holding settings for running a specific script
Scripts run in two host modes. WScript.exe executes them in windowed mode, while CScript.exe runs them at the command line. WSH can also be invoked as a COM object through scrobj.dll. Third-party engines exist for languages such as PerlScript, Python, Ruby, Tcl, and Rexx, so a .WSF file may reference engines that are not installed by default.
How these files are structured
.VBS, .JS, .VBE, and .JSE files are not databases or binary containers. They are plain text (or encoded text) read line by line by the script engine. There is no header, no index, and no internal checksum. A script either parses completely or fails at the first syntax error the engine encounters.
.WSF files are different. They are XML documents with a defined job and script element structure, so a malformed tag, a broken CDATA section, or a truncated file produces an immediate parse failure. Encoded .VBE and .JSE files are produced by the Microsoft Script Encoder, which applies an obfuscation scheme rather than true encryption. Damage to an encoded file usually makes it entirely unrecoverable in its original form, because the decoder needs the encoded stream intact from start to finish.
Why WSH files fail to run or appear corrupt
Most "corrupt script" reports are not file damage at all. The common causes are:
- Truncation, when a file was edited over a network share, saved during a power loss, or copied incompletely, leaving an unterminated string or block
- Encoding mismatch, when a file saved in one code page or Unicode form is read as another, corrupting non-ASCII characters and string literals
- Missing engines, when a .WSF file calls for a third-party engine that is not installed on the machine
- Security policy, since Windows and antivirus products increasingly block VBScript and JScript by default; Microsoft has been deprecating VBScript and turning it into an on-demand feature
- Line-ending or editor damage, when a script edited in a word processor picks up smart quotes or rich-text artifacts that break parsing
- Malware tampering, since WSH files have long been abused by script-based malware, and an antivirus quarantine or partial disinfection can leave a script in a broken state
Because these files are plain text, true physical corruption is rare. The failure usually sits in the script's logic, its environment, or the policy layer around WSH.
What can be recovered from a damaged script file
Recovery depends on the file type. From a truncated or mangled .VBS or .JS file, we can typically recover the surviving text, reconstruct missing structure such as closing statements, and identify exactly where the file broke. From a damaged .WSF file, we can repair the XML structure and salvage the individual job blocks inside it.
Encoded .VBE and .JSE files are the hard case. If the encoded stream is intact but the file will not run, the problem is environmental and fixable. If the stream itself is damaged, the original source usually cannot be reconstructed, and the realistic outcome is a partial decode or a rewrite based on the script's observed behavior.
Where a script has been quarantined by security software, recovery means extracting the file from quarantine, not repairing bytes, then deciding deliberately whether it is safe to restore.
How script recovery works
Our engineers start by examining the file in a controlled environment, never by double-clicking it, since WSH files are executable content. We inspect the raw bytes to determine encoding, detect truncation points, and check for editor artifacts. For .WSF files we validate the XML structure and isolate the failing element.
We then rebuild the file: restoring line endings and encoding, repairing structure, and testing it under CScript.exe with logging so errors surface at the command line rather than in a silent windowed failure. Where the original cannot be fully recovered, we document what was salvaged and can often reconstruct the script's logic from the surviving fragments.
If a script fails because of policy rather than damage, we will tell you that plainly, because the fix is a configuration change, not a repair.
Frequently asked questions
Is a .VBS file a data file that can be repaired like a document?
No. It is executable plain text. There is no internal structure to rebuild, so recovery means fixing the text, the encoding, or the environment, not extracting records from a container.
Can an encoded .VBE file be decoded back to readable VBScript?
Only if the encoded stream is fully intact. The Script Encoder's scheme is reversible, so an undamaged .VBE can be returned to source. A truncated or corrupted one generally cannot.
Why did my script stop working after a Windows update?
Recent Windows versions restrict VBScript and JScript for security, and Microsoft is phasing out VBScript. Your file may be undamaged while the engine needed to run it is disabled or removed.
Is it safe to open a WSH file to check whether it is damaged?
Not by double-clicking. WSH files execute when opened. Inspection should be done in a text editor or a sandbox, and this is how our evaluation process handles every file we receive.
Get a free evaluation
If a mission-critical logon script, administration script, or .WSF automation file has stopped working, send it to us for a free evaluation. Our engineers will tell you quickly whether the file is damaged, blocked by policy, or recoverable, and what a repair would involve.
Send us your .vbe file for a free evaluation
Our recovery engineers will tell you exactly what can be recovered — at no cost. There is no charge if we cannot recover your data.
Start a free evaluation