ActiveXperts Scripting Toolkit
Manual Pages


© 1999-2005 - ActiveXperts Software
http://www.activexperts.com
info@activexperts.com




Table of Contents


  1. Introduction
  2. System Requirements
  3. Installation
  4. How to use ActiveXperts Scripting Toolkit
  5. Scripting object
  6. Completion object
  7. Error Codes
  8. Samples
  9. Troubleshooting
  10. License Agreement
  11. Purchase and Product Activation





1. Introduction


1.1. What is ActiveXperts Scripting Toolkit?

ActiveXperts Scripting Toolkit enables IT administrators and Software Developers to call VBScript functions without invoking the 'Windows Scripting Host'.

Usually, you call VBScript programs by invoking the 'Windows Script Host' (either WSCRIPT.EXE or CSCRIPT.EXE). The ActiveXperts Scripting Toolkit directly communicates with the VBScript Engine of the operating system. Some benefits of using ActiveXperts Scripting Toolkit:
  • No need to redirecting standard error and standard output; function results are available for further use after the function has completed;
  • Call functions directly instead of writing 'stub' code;
  • Pass function parameters dynamically - pass the function parameters 'on the fly', directly from your own application or script;
  • Set a timeout to prevent functions from not returning, for instance because of an endless loop;
  • Intercept program errors that would normally crash the Windows Scripting Host;
  • Customize your error messages;
  • Support for Windows Services - you can call a VBScript function directly from a Windows Service.
ActiveXperts Scripting Toolkit is a ActiveX/COM component, that provides an easy-to-use scripting interface for companies who - somehow - want VBScript integration in their software. ActiveXperts Scripting Toolkit features the following:
  • Call functions directly;
  • Pass up to 8 parameters;
  • Comprehensive Function return information
  • Comprehensive Script completion information
  • Ability to set a time-out, preventing scripts from never completing;
  • Robust script handing - bad scripts that would usually make a sub-system crash are intercepted by the toolkit;
  • Thread safe - the Toolkit can be used in any multi-threading (and multi-processing) environment;
  • Support for Windows Services;
  • Advanced error handling;
  • Advanced logging.
ActiveXpert Scripting Toolkit includes samples for many development tools, including:
  • Visual Basic .NET - Windows .NET based applications;
  • Visual C# .NET - Windows .NET based applications;
  • Visual Basic 5.x or higher - Windows based applications;
  • Visual C++ 5.x or higher - Windows based applications;
  • ASP - Web sites based on Active Server Pages;
  • ASP .NET - Web sites based on Active Server Pages and the .NET Framework;
  • VBScript - Windows based scripts;
  • Any other development platform that supports ActiveX/COM components.

1.2. ActiveXperts Scripting Toolkit Architecture

ActiveXperts Scripting Toolkit makes use of the Microsoft VBScript Engine. It only makes use of the engine; it doesn't replace any VBScript engine components.

The core of ActiveXperts Scripting Toolkit consists of one file:
  1. AxScript.dll - the actual ActiveX/COM component;

ActiveXperts Scripting Toolkit can be distributed easily to multiple PC's. Once you have purchased the licenses, you copy the AxScript.dll to the PCs and register the DLL on that PC.





2. System Requirements


2.1. ASP .NET, VB .NET, VC# .NET, ASP, VB, Visual C++ and more

The ActiveXperts Scripting Toolkit component can be used by any of these development/scripting languages:
  • ASP .NET;
  • Visual Basic .NET;
  • Visual C# .NET;
  • ASP 2.x
  • VBScript;
  • HTML - Client scripts within HTML pages - requires Internet Explorer 4.x or higher;
  • Visual Basic 5.x/6.x;
  • Visual C++ 5.x/6.x.

2.2. .NET Framework

To use ActiveXperts Scripting Toolkit in an ASP .NET, Visual Basic .NET or Visual C#. NET environment, the .NET Framework must be installed on the system. The .NET Framework is part of the Windows 2003 Operating System. On Windows 2000, Windows 98, Windows ME, Windows NT, Windows Server 2003, Windows XP, it's available as a separate installation. Please visit the Technology Information for the .NET Framework page to download the .NET Framework.


2.3. Internet Information Server

Internet Information Server (IIS) Setup installs the Visual Basic Script and Java Script engines.

To run ASP pages on NT4 Servers, IIS 4.x must be installed. IIS 4.x ships with the NT4 Option Pack CD's.
To run ASP pages on Windows 2000 Servers, IIS 5.x must be installed. IIS is part of the Windows 2000/2003 Operating System.


2.4. Internet Explorer 4.x or higher

The Internet Explorer 4.x Setup (or higher) installs the Visual Basic Script and Java Script engines.
You can use the ActiveXperts Scripting Toolkit component from within the client HTML code.


2.5. Windows Scripting Host

ActiveXperts Scripting Toolkit can be used in VBScript scripts. VBScripts can be used by passing the script-file as a parameter to the scripting host ( either 'cscript' or 'wscript').
WSH relies on the Visual Basic Script and Java Script engines provided with Internet Explorer 4.x or later. WSH is also installed as part of Windows 98, Windows 2000, and Internet Information Services 4.0. A separate setup program is provided for Windows 95.


2.6. Visual Basic

ActiveXperts Scripting Toolkit can be used in Visual Basic 5.x or higher.


2.7. Visual C++

ActiveXperts Scripting Toolkit can be used in Visual C++ 5.x or higher.



3. Installation

The ActiveXperts Scripting Toolkit package consists of 3 components; any combination of components can be installed:
  1. The ActiveXperts Scripting Toolkit COM component - the interface to COM compliant applications;
  2. The ActiveXperts Scripting Toolkit Help Files - documentation;
  3. The ActiveXperts Scripting Toolkit Example Files - examples.

3.1. Installation on a single computer

Simply run the AxScript.exe Setup program. The InstallShield wizard will guide you through the rest of the setup.
If you choose the ActiveXperts Scripting Toolkit COM component, the Setup program can perform the registration of the COM component for you. But it will also give you the opportunity to register the object yourself.

Any subsequent installation of ActiveXperts Scripting Toolkit can be performed either manually or by using the Setup program.


3.2. Installation on multiple computers

Any subsequent installations can be performed using the setup program.
But since the installation of the core components is very simple, you may want to do it manually, or integrate it into your companies software distribution program.

If you choose to install the COM component manually on other machines, simply perform the following actions:
  • Copy the AxScript.dll (the ActiveXperts Scripting Toolkit COM component) to a destination location on the new machine;
  • Register the COM component by using the following command: REGSVR32 <dest-location>\AxScript.dll




4. How to use the ActiveXperts Scripting Toolkit object


4.1. Introduction


The following code snippets illustrate how to use ActiveXperts Scripting Toolkit.


Calling a VBScript function from a VC++ application


   int main(int argc, char* argv[])
   {
      HRESULT          hResult;
      IXScripting      *pScript   = NULL;
      IXCompletion     *pResponse = NULL;
      LONG             lResult   = 0L, lLastError = 0L;
      BSTR             bstrTemp  = NULL;
      VARIANT          vtVar;

      VariantInit ( &vtVar );	

      hResult = CoInitialize (NULL);		 // Initialize COM
      if (FAILED (hResult)) goto _EndMain;

      // Create an instance of the 'ActiveXperts.Scripting' class	
      hResult = CoCreateInstance ( CLSID_XScripting,  NULL, CLSCTX_INPROC_SERVER, IID_IXScripting, (void**) &pScript);
      if (FAILED (hResult)) goto _EndMain;

      pScript->Clear ();                     // Clear the object

      // Assign the actual VBScript program file that contains the function you want to call
      pScript->put_ScriptFile ( _bstr_t ( "C:\\My Scripts\Script.vbs" ) );
	
      // Assign function name
      pScript->put_Function( L"GetDirectorySize");

      // Assign paramater(s). Use Parameter1, Parameter2, .., Parameter8
      pScript->put_Parameter1( L"\"C:\\Windows\"" );

      // No run the script
      pScript->Run ( &vtVar );

      // If Run didn't return a valid VARIANT pointer then exit
      if( vtVar.vt != VT_DISPATCH || ( pResponse = ( IXCompletion* ) vtVar.pdispVal ) == NULL )
         goto _EndMain;

      // Get the results ...

      pResponse->get_CompletionCode ( &lResult );
      printf ( "Completion Code               = %ld\n", lResult );
	
      pResponse->get_CompletionDescription ( &bstrTemp );
      printf ( "Completion Description        = %ls\n", bstrTemp );
      SysFreeString ( bstrTemp );

      if( lResult == 0 )
      {
          pResponse->get_FunctionReturnNumber( &lResult );
          printf ( "Function Return Number          = %ld\n", lResult );

          pResponse->get_FunctionReturnString( &bstrTemp );
          printf ( "Function Return String        = %ls\n", bstrTemp );
          SysFreeString ( bstrTemp );

          pResponse->get_FunctionReturnInfo( &bstrTemp );
          printf ( "Function Return Info          = %ls\n", bstrTemp );
          SysFreeString ( bstrTemp );
      }
      else
      {
          pResponse->get_CompletionErrorSource( &bstrTemp );
          printf ( "CompletionErrorSource         = %ls\n", bstrTemp );
          SysFreeString ( bstrTemp );

          pResponse->get_CompletionErrorDescription( &bstrTemp );
          printf ( "CompletionErrorDescription    = %ls\n", bstrTemp );
          SysFreeString ( bstrTemp );

          pResponse->get_CompletionErrorLine( &lResult );
          printf ( "CompletionErrorLine           = %ld\n", lResult );

          pResponse->get_CompletionErrorChar( &lResult );
          printf ( "CompletionErrorChar           = %ld\n", lResult );

          pResponse->get_CompletionErrorCode( &lResult );
          printf ( "CompletionErrorCode           = %ld\n", lResult );
      }

   _EndMain:
      VariantClear ( &vtVar );
      return 0;
   }

Calling a VBScript function from a VBScript program

   Set objScripting                      = CreateObject( "ActiveXperts.Scripting" )' Create a new Scripting instance

   objScripting.ScriptFile               = "C:\My Scripts\Script.vbs"              ' Set script file      
   objScripting.Function                 = "GetDateAndTime"                        ' Set script function 
   Set objCompletion                     = objScripting.Run                        ' Run the script

   WScript.Echo "CompletionCode          : " & objCompletion.CompletionCode        ' Result (numeric) of the script execution
   WScript.Echo "CompletionDescr.        : " & objCompletion.CompletionDescription ' Result (friendly string) of the script execution

   If( objCompletion.CompletionCode = 0 ) Then
     WScript.Echo "FunctionReturnNumber  : " & objCompletion.FunctionReturnNumber  ' Return value (Number) of the function
     WScript.Echo "FunctionReturnString  : " & objCompletion.FunctionReturnString  ' Return value (String) of the function
     WScript.Echo "FunctionReturnInfo    : " & objCompletion.FunctionReturnInfo    ' Return value (Variant) of the function
   Else
     WScript.Echo "CompletionErrorSource : " & objCompletion.CompletionErrorSource ' Shows in which script the error occured
     WScript.Echo "CompletionErrorDescription : " & objCompletion.CompletionErrorDescription ' Gives a short description of the error
     WScript.Echo "CompletionErrorLine   : " & objCompletion.CompletionErrorLine   ' Shows in which line the error occured 
     WScript.Echo "CompletionErrorChar   : " & objCompletion.CompletionErrorChar   ' Shows on which character position the error occured 
     WScript.Echo "CompletionErrorCode   : " & objCompletion.CompletionErrorCode   ' Shows the Microsoft VBScript Engine error code
   End If


4.2. How to use ActiveXpert Scripting Toolkit in Visual Basic .NET

First, make sure the ActiveXperts Scripting Toolkit component (AxScript.dll) is registered on the machine. In case you didn't use the installation program, be sure you used the REGSVR32.EXE program to register to component.

Then, add a reference to the ActiveXpert Scripting Toolkit component using the Visual Basic .NET Solution Explorer:
  1. Start the Solution Provider, go to the project's 'References' container;
  2. Choose 'Add Reference' from the context menu;
  3. From the COM components tab, choose the ActiveXpert Scripting Toolkit component.
On top of your code, make this declaration:
  Imports AxScript
Declare and create an object like this:
   Dim objScripting As XScripting                    ' Declaration
   Dim objCompletion As XCompletion                  ' Declaration
	
   objScripting = New XScripting()                   ' Creation
   ...
   objCompletion = objScripting.Run()                ' Run returns an XCompletion object
The product installation contains working VB .NET samples.
They can also be found online: ftp.activexperts-labs.com/samples/axscript.



4.3. How to use ActiveXperts Scripting Toolkit in Visual C# .NET

First, make sure the ActiveXperts Scripting Toolkit component (AxScript.dll) is registered on the machine. In case you didn't use the installation program, be sure you used the REGSVR32.EXE program to register to component.

Then, add a reference to the object using the Visual C# Solution Explorer:
  1. Start the Solution Provider, go to the project's 'References' container;
  2. Choose 'Add Reference' from the context menu;
  3. From the COM components tab, choose the ActiveXperts Scripting Toolkit component.
On top of your code, make this declaration:
  using AxScript;
and declare and create an object like this:
   XScripting  objScripting = new XScripting();              // Declaration
   XCompletion objCompletion;                                // Declaration
   ...
   objScripting = new Scripting();                           // Creation
   ...
   objCompletion = objScripting.Run();                       // Run returns an XCompletion object
After the declaration and creation of the object, you can use the object in your Visual C# .NET code.
Visual C# .NET samples are part of the product installation.
They can also be found online: ftp.activexperts-labs.com/samples/axscript.



4.4. How to use ActiveXperts Scripting Toolkit in Visual Basic

ActiveXperts Scripting Toolkit can be used in Visual Basic 5.x or higher. In Visual Basic, go to the 'Project/References...' menu item and check the box next to ActiveXpert Scripting Toolkit Type Library. Now, you can declare and create ActiveXpert Scripting Toolkit objects.

Create a new ActiveXpert Scripting Toolkit object using the 'CreateObject' function:

  Dim objScripting As AxScript.XScripting                     ' Declaration
  Dim objCompletion As AxScript.XCompletion                   ' Declaration
  ...
  Set objScripting = CreateObject( "ActiveXperts.Scripting")  ' Creation
  ...
  objCompletion = objScripting.Run()                          ' Run returns an XCompletion object
After the declaration and creation of the object, you can use the object in your Visual Basic code.
Visual Basic samples are part of the product installation.
They can also be found online: ftp.activexperts-labs.com/samples/axscript.



4.5. How to use ActiveXperts Scripting Toolkit in Visual C++

ActiveXperts Scripting Toolkit can be used in Visual C++ projects. Include the *.h and *.c file provided by ActiveXperts to bind your code to the ActiveXperts Scripting Toolkit component. These files are located in the Include directory of the Visual C++ samples directory. These are the files:
  • AxScript.h
  • AxScript_i.c
Create the various ActiveXpert Scripting Toolkit object instances like this:

   IXScripting  *pScript;                            // Declaration        
   IXCompletion *pCompletion                         // Declaration 
   ...                       
   CoCreateInstance ( CLSID_XScripting ,  NULL, CLSCTX_INPROC_SERVER, IID_IXScripting, (void**) &pScript);           // Creation
   ...
   pScript->Run ( &vtVar );                          ' Run copies an IXCompletion object
   pCompletion = ( IXCompletion* ) vtVar.pdispVal;
   ...
After the declaration and creation of the object, you can use the object in your Visual C++ code.
Visual C++ samples are part of the product installation.
They can also be found online: ftp.activexperts-labs.com/samples/axscript.



4.6. How to use ActiveXpert Scripting Toolkit in an ASP 2.x environment

  <html>
  <body>
  Version:
  <script language=vbscript runat=server>
    Set objScripting = CreateObject( "ActiveXperts.Scripting" )
    Response.Write objScripting.Version
  </script>
  </body>
  </html>
ASP samples are part of the product installation.
They can also be found online: ftp.activexperts-labs.com/samples/axscript.




5. Scripting Object


5.1. Scripting object - Properties and Functions Overview


Property Type In/Out Mand/Opt Description
Version String Out n/a Version number of ActiveXpert Scripting Toolkit
ExpirationDate String Out n/a Expiration date of ActiveXpert Scripting Toolkit
ScriptFile String In/Out M Full-path script file location
Function String In/Out M Function to call
Parameter1 String In/Out O 1st parameter (if available)
Parameter2 String In/Out O 2nd parameter (if available)
Parameter3 String In/Out O 3rd parameter (if available)
Parameter4 String In/Out O 4th parameter (if available)
Parameter5 String In/Out O 5th parameter (if available)
Parameter6 String In/Out O 6th parameter (if available)
Parameter7 String In/Out O 7th parameter (if available)
Parameter8 String In/Out O 8th parameter (if available)
Timeout Number In/Out O Script timeout (in milliseconds)
LogFile String In/Out O Log file used for troubleshooting purposes

Function Description
Clear Clear all properties
Run Run the seleected function in the selected script
Activate Activate the product



5.2. ActiveXpert Scripting Toolkit object - Properties


 Version property

Description:
Version information of ActiveXpert Scripting Toolkit. This property is read-only; you cannot assign a value to it.

Example:
   Set objScripting = CreateObject("ActiveXperts.Scripting")   ' Create a new Scripting instance
   WScript.Echo  "Version: " & objScripting.Version

 ExpirationDate property

Description:
Expiration date of ActiveXpert Scripting Toolkit. This property is read-only; you cannot assign a value to it.
Once you have registered the product, the property holds the empty string ("") value.

Example:
   Set objScripting = CreateObject("ActiveXperts.Scripting")   ' Create a new Scripting instance
   WScript.Echo "ExpirationDate: " & objScripting.ExpirationDate

 ScriptFile property

Description:
The VBScript file that contains the function that you wish to run.

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   Set objCompletion       = objScripting.Run()                             ' Run the function
   WScript.Echo "CompletionCode   : " & objCompletion.CompletionCode        ' Result of the script execution
   WScript.Echo "CompletionDescr. : " & objCompletion.CompletionDescription ' Result of the script execution
   ...

 Function property

Description:
The function that is called when run is invoked.

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   Set objCompletion       = objScripting.Run()                             ' Run the function
   WScript.Echo "CompletionCode   : " & objCompletion.CompletionCode        ' Result of the script execution
   WScript.Echo "CompletionDescr. : " & objCompletion.CompletionDescription ' Result of the script execution
   ...

 Parameter1 property
 Parameter2 property
 Parameter3 property
 Parameter4 property
 Parameter5 property
 Parameter6 property
 Parameter7 property
 Parameter8 property

Description:
The parameters to be passed to the function. NOTE: String parameters must be enclosed by double quotes (like: "My First Parameter")

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   objScripting.Parameter1 = 1                                              ' Numeric parameter
   objScripting.Parameter2 = "Sunday"                                       ' String parameter
   objScripting.Parameter3 = 2                                              ' Numeric paramater
   objScripting.Parameter4 = "Monday"                                       ' String parameter
   Set objCompletion       = objScripting.Run()                             ' Run the function
   WScript.Echo "CompletionCode   : " & objCompletion.CompletionCode        ' Result of the script execution
   WScript.Echo "CompletionDescr. : " & objCompletion.CompletionDescription ' Result of the script execution
   ...

 TimeOut property

Description:
Number of milliseconds before the Run method will time-out. Use this 'Timeout' propery to ensure that Run returns control in case that the called Function does not return, for instance because of an endless loop.

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   objScripting.Timeout    = 5000                                           ' Allow 5000 milliseconds for the 'Func1' function to complete
   ...
   Set objCompletion       = objScripting.Run()                             ' Run the function
   ...

 LogFile property

Description:
By default, LogFile holds the empty string and nothing is logged. If you assign a valid file name to it, tracing information is written to the log file. This information can be used for troubleshooting purposes.

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.LogFile    = "C:\MyLogFile.txt"                             ' All operations are logged here
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   ...
   Set objCompletion       = objScripting.Run()                             ' Run the function
   ...


5.3. ActiveXperts Scripting Toolkit object - Functions


 Clear function

Description:
Clear all properties. It is recommended to use this function when an instance is used multiple times, to make sure the object is cleared after each call to the Run function.

Parameters:
  • None
Return value:
Always success

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   
   objScripting.Function   = "Func1"                                        
   ...
   Set objCompletion       = objScripting.Run()                             ' Run 'Func1'
   ...
   ...
   objScripting.Clear()                                                     ' Clear all properties
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   
   objScripting.Function   = "Func2"                                        
   ...
   Set objCompletion       = objScripting.Run()                             ' Run 'Func2'
   ...

 Run function

Description:
Call the function indicated by the Function property in the files indicated by the ScriptFile property.
The results of the call will be returned as a new Completion object.

Parameters:
  • None
Return value:
An instance of the Completion object, specifying the results of the function.

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   objScripting.Parameter1 = 1                                              ' Numeric parameter
   Set objCompletion       = objScripting.Run()                             ' Run the function

   WScript.Echo "CompletionCode   : " & objCompletion.CompletionCode        ' Result of the script execution
   WScript.Echo "CompletionDescr. : " & objCompletion.CompletionDescription ' Result of the script execution

   If( objCompletion.CompletionCode = 0 ) Then
     WScript.Echo "FunctionReturnNumber  : " & objCompletion.FunctionReturnNumber  ' Return value (Number) of the function
     WScript.Echo "FunctionReturnString  : " & objCompletion.FunctionReturnString  ' Return value (String) of the function
     WScript.Echo "FunctionReturnInfo    : " & objCompletion.FunctionReturnInfo    ' Return value (Variant) of the function
   Else
     WScript.Echo "CompletionErrorSource : " & objCompletion.CompletionErrorSource ' Only set if CompletionCode <> 0; shows in which script the error occured
     WScript.Echo "CompletionErrorDescription : " & objCompletion.CompletionErrorDescription ' Only set if CompletionCode <> 0; gives a short description of the error
     WScript.Echo "CompletionErrorLine   : " & objCompletion.CompletionErrorLine   ' Only set if CompletionCode <> 0; shows in which line the error occured 
     WScript.Echo "CompletionErrorChar   : " & objCompletion.CompletionErrorChar   ' Only set if CompletionCode <> 0; shows on which character position the error occured 
     WScript.Echo "CompletionErrorCode   : " & objCompletion.CompletionErrorCode   ' Only set if CompletionCode <> 0; shows the Microsoft VBScript Engine error code
   End If

 Activate function

Description:
This function activates the ActiveXpert Scripting Toolkit product. A valid registrationcode must be passed as parameter.

Parameters:
The registration code

Return value:
Always 0.

Example:
   Set objScripting = CreateObject("ActiveXperts.Scripting")       ' Create a new Scripting instance
   objScripting.Activate "xxxxx-xxxxx-xxxxx"                      ' Use a valid registration code






6. Completion Object


6.1. Completion object - Properties and Functions Overview


Property Type In/Out Mand/Opt Description
CompletionCode Number Out n/a Result (numeric) of the last 'Run' call
CompletionDescription String Out n/a Result (friendly string) of the last 'Run' call
FunctionReturnNumber Number Out n/a If function returns a numeric value, this property holds the actual return value after completion
FunctionReturnString String Out n/a If function returns a string value, this property holds the actual return value after completion
FunctionReturnInfo Variant Out n/a If function returns a Variant, this property holds the actual return value after completion
CompletionErrorSource String Out n/a Source file that contains the error
CompletionErrorDescription String Out n/a Description of the error
CompletionErrorLine Number Out n/a Line number in source code where error occured
CompletionErrorChar Number Out n/a Character position in source code where error occured
CompletionErrorCode Number Out n/a Microsoft VBScript Engine error code



6.2. Completion object - Properties


 CompletionCode property,
 CompletionDescription property.


Description:
Result of the last Run call.

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   ...
   Set objCompletion       = objScripting.Run()                             ' Run the function
   If( objCompletion.CompletionCode = 0 )
      WScript.Echo "Sucess!"
   Else
      WScript.Echo "CompletionCode        : " & objCompletion.CompletionCode        ' Completion information of the function call      
      WScript.Echo "CompletionDescription : " & objCompletion.CompletionDescription ' Completion information of the function call 
  End If
   ...


 FunctionReturnNumber property,
 FunctionReturnString property,
 FunctionReturnInfo property.


Description:
Return value of the last Run call. Only one the prtoperties will be assigned, depending on the datatype.
If the function returns a numeric value, then 'FunctionReturnNumber' will hold the return value; if the function returns a string value, then 'FunctionReturnString' will hold the return value; if the function returns a Variant value, then 'FunctionReturnInfo' will hold the return value.

Example:
   Set objScripting        = CreateObject("ActiveXperts.Scripting")         ' Create a new Scripting instance
   ...
   objScripting.ScriptFile = "c:\my scripts\myscript.vbs"                   ' myscript.vbs is the script that holds function 'Func1'
   objScripting.Function   = "Func1"                                        ' Call 'Func1' when Run is invoked
   ...
   Set objCompletion       = objScripting.Run()                             ' Run the function
   If( objCompletion.CompletionCode = 0 )
      WScript.Echo "Return String  : " & objCompletion.FunctionReturnString ' Return value of the function call (only if type is numeric)    
      WScript.Echo "Return Number  : " & objCompletion.FunctionReturnNumber ' Return value of the function call (only if type is a string)  
      WScript.Echo "Return Info    : " & objCompletion.FunctionReturnInfo   ' Return value of the function call (only if type is a Variant)  
   Else
      WScript.Echo "CompletionCode        : " & objCompletion.CompletionCode    
      WScript.Echo "CompletionDescription : " & objCompletion.CompletionDescription 
  End If
   ...


 CompletionErrorSource property,
 CompletionErrorDescription property,
 CompletionErrorLine property,
 CompletionErrorChar property,
 CompletionErrorCode property.


Description:
These properties are set when Run failed (i.e. when CompletionCode is not equal to 0).

CompletionErrorSource - Source file that contains the error
CompletionErrorDescription - Description of the error
CompletionErrorLine - Line number in source code where error occured
CompletionErrorChar - Character position in source code where error occured
CompletionErrorCode - Microsoft VBScript Engine error code

Example:
   Set objScripting                      = CreateObject( "ActiveXperts.Scripting" )' Create a new Scripting instance

   objScripting.ScriptFile               = "C:\My Scripts\Script.vbs"              ' Set script file      
   objScripting.Function                 = "GetDateAndTime"                        ' Set script function 
   Set objCompletion                     = objScripting.Run                        ' Run the script

   WScript.Echo "CompletionCode          : " & objCompletion.CompletionCode        ' Result (numeric) of the script execution
   WScript.Echo "CompletionDescr.        : " & objCompletion.CompletionDescription ' Result (friendly string) of the script execution

   If( objCompletion.CompletionCode = 0 ) Then
     WScript.Echo "FunctionReturnNumber  : " & objCompletion.FunctionReturnNumber  ' Return value (Number) of the function
     WScript.Echo "FunctionReturnString  : " & objCompletion.FunctionReturnString  ' Return value (String) of the function
     WScript.Echo "FunctionReturnInfo    : " & objCompletion.FunctionReturnInfo    ' Return value (Variant) of the function
   Else
     WScript.Echo "CompletionErrorSource : " & objCompletion.CompletionErrorSource ' Only set if CompletionCode <> 0; shows in which script the error occured
     WScript.Echo "CompletionErrorDescription : " & objCompletion.CompletionErrorDescription ' Only set if CompletionCode <> 0; gives a short description of the error
     WScript.Echo "CompletionErrorLine   : " & objCompletion.CompletionErrorLine   ' Only set if CompletionCode <> 0; shows in which line the error occured 
     WScript.Echo "CompletionErrorChar   : " & objCompletion.CompletionErrorChar   ' Only set if CompletionCode <> 0; shows on which character position the error occured 
     WScript.Echo "CompletionErrorCode   : " & objCompletion.CompletionErrorCode   ' Only set if CompletionCode <> 0; shows the Microsoft VBScript Engine error code
   End If






7. Errors

The completion code of the Run function is stored in the CompletionCode property.
When CompletionCode is 0, it means that the Run function completed successfully; otherwise, an error occured.

All completion codes are listed on the ActiveXperts web site: www.activexperts.com/support/errorcodes.






8. Samples

Samples for Visual Basic, Visual Basic .NET, Visual C++, Visual C# .NET, ASP and VBScript are included as part of the installation. You can also find the samples on our website at ftp.activexperts-labs.com/samples/axscript.





9. Troubleshooting


FAQ's

Visit our website for a complete list of FAQ's at:
    http://www.activexperts.com/support


Contact us

Please contact our website for support questions about this product, or send an email to our support-staff:

Website: http://www.activexperts.com/support
Email: support@activexperts.com




10. License Agreement

You should carefully read the following terms and conditions before using this software. Your use of this software indicates your acceptance of this license agreement and warranty.

Shareware Version

You are hereby licensed to:
Use the shareware version of the software for a 30 day evaluation period; make as many copies of the unregistered shareware version of this software as you wish; give exact copies of the original unregistered shareware version to anyone; and distribute the unregistered shareware version of the software in its unmodified form via electronic means. There is no charge for any of the above.
The software may be not be sold for a fee on diskette or CD-ROM, either alone or as part of a collection with other products, without prior permission of ActiveXperts Software. (with the exception of magazine cover CD-ROMs that are sold with a magazine, which require no permission).
Unregistered use of ActiveXperts software after the 30-day evaluation period is in violation of federal copyright laws.


Disclaimer of Warranty

THIS SOFTWARE AND THE ACCOMPANYING FILES ARE PROVIDED "AS IS" AND WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED OR IMPLIED. NO WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.
Good data processing procedure dictates that any program be thoroughly tested with non-critical data before relying on it. The user must assume the entire risk of using the program. ANY LIABILITY OF THE SELLER WILL BE LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.

Copyright 1999-2001 ActiveXperts software. http://www.activexperts.com




11. Purchase and Product Activation


Purchase

Please visit www.activexperts.com/sales to buy the product. Here, you can also find the latest prices.

You can also contact us via email: sales@activexperts.com

After you purchase the product, you will receive one or more product registration keys.



Product Activation

After you purchase the product, you will receive a registration code. This code must be entered on your machine(s). You can do this by using the actual ActiveXpert Scripting Toolkit component:
   Set objScripting = CreateObject("ActiveXperts.Scripting") ' Create a new Scripting instance
   objScripting.Activate XXXXX-XXXXX-XXXXX"                  ' Replace XXXXX-XXXXX-XXXXX by your own registration code

Or you can activate by (re)installing the product using the Setup program. The InstallShield wizard will prompt for the registration code.

Or you can activate by editing the registry:
  1. Start the registry editor (either REGEDT32.EXE or REGEDIT.EXE);
  2. open the 'HKEY_LOCAL_MACHINE\Software\ActiveXperts\ActiveXpert Scripting Toolkit' key;
  3. Add/modify the 'RegistrationKey' value: Type: REG_SZ, Value: XXXXX-XXXXX-XXXXX