Jump to content

VBScript Variable undefined: Wscript


Scott Smith
 Share

Recommended Posts

I have a simple section of VBScript in one web page that is attempting to use AutoIT to activate another web page and send a few characters to it. When I reload the page, I get an error message stating: Error: Variable is undefined: 'WScript'

The code is:

<script language=vbscript>

Option Explicit

Dim oAutoIt

Set oAutoIt = WScript.CreateObject("AutoItX3.Control") 'this is the line that generates the error

oAutoIt.WinActive "ePort - ACROFile Input - Microsoft Internet Explorer", ""

oAutoIt.Send "Smith{ENTER}Scott"

WScript.Quit

</script>

Any thoughts would be greatly appreciated.

Link to comment
Share on other sites

Scott it sounds like you need to register the dll. If you didn't install the AutoIt package (Which contains autoitx.dll, then type the following at a command prompt:

regsvr32 c:\windows\system32\autoitx.dll

or whatever path is appropriate.

Link to comment
Share on other sites

Scott, used within a Web page VBScript defines a global scope function CreateObject, WScript object is indeed undefined, so type:

Set oAutoIt = CreateObject("AutoItX3.Control")

instead of:

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

Note also, that IE would ususally prompt you several times to confirm object activation.

UDFS & Apps:

Spoiler

DDEML.au3 - DDE Client + Server
Localization.au3 - localize your scripts
TLI.au3 - type information on COM objects (TLBINF emulation)
TLBAutoEnum.au3 - auto-import of COM constants (enums)
AU3Automation - export AU3 scripts via COM interfaces
TypeLibInspector - OleView was yesterday

Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCEĀ 

Link to comment
Share on other sites

Thanks. About five minutes after posting that message I said to myself, "Self, why not just try CreateObject without the WScript?" Surprise, surprise, it worked. The WScript of course was working fine in the WIndows Script Host but not VBScript. Now it all makes sense. Thank you much for the input.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...