Pro.WScript — API for parsing Windows Script files

Overview

The Pro.WScript module contains the API for parsing Windows Script files such as VBS, VBE, JS and JSE.

Decoding a Windows Script file

Windows Script files can be encoded (VBE and JSE). The following code example demonstrates how to decode them:

from Pro.Core import *
from Pro.WScript import *

def decodeWScript(fname):
    c = createContainerFromFile(fname)
    if c.isNull():
        return NTContainer()
    obj = WScriptObject()
    if not obj.Load(c):
        return NTContainer()
    if not obj.IsEncoded():
        print("warning: the object is not encoded!")
        return c
    return obj.GetDecoded()

Module API

Pro.WScript module API.

Classes:

WScriptObject()

This class represents a Windows Script file.

class WScriptObject

Bases: Pro.Core.CFFObject

This class represents a Windows Script file.

Methods:

Decode()

Decodes the Windows Script in place.

GetDecoded()

Decodes the Windows Script data.

IsEncoded()

Returns True if the script is encoded; otherwise returns False.

WasEncoded()

Returns True if the script was encoded before calling Decode(); otherwise returns False.

Decode()bool

Decodes the Windows Script in place.

Hint

This method internally calls GetDecoded() followed by Pro.Core.CFFObject.ReplaceStream().

Returns

Returns True if successful; otherwise returns False.

Return type

bool

See also IsEncoded() and GetDecoded().

GetDecoded()Pro.Core.NTContainer

Decodes the Windows Script data.

Returns

Returns the decoded data if successful; otherwise returns an invalid Pro.Core.NTContainer instance.

Return type

NTContainer

See also IsEncoded() and Decode().

IsEncoded()bool
Returns

Returns True if the script is encoded; otherwise returns False.

Return type

bool

See also GetDecoded() and Decode().

WasEncoded()bool
Returns

Returns True if the script was encoded before calling Decode(); otherwise returns False.

Return type

bool

See also IsEncoded() and Decode().