Skip to Content

Hello community,

Windows offers the possibility to define Windows Script Components (WSC), also known as Scriptlets.  This means you can compile a script file to a type library, register the WSC file and use it inside any other programming language as a COM object, e.g. like ABAP. You find detailed information about WSC on the Microsoft Technet here.

At first you must define a WSC file. A WSC file is a XML file. To define a WSC you can use the Microsofts Windows Script Component Wizard from here. In six steps you can create a WSC. You can use different Active Scripting Engines – a similar example see here.

Here an example with VBScript and JScript:

<?xml version="1.0"?>
    Compile this Windows Scripting Component (WSC) to a typelibrary with
    the command: rundll32 scrobj.dll,GenerateTypeLib ABAPTest.wsc
      -file:ABAPTest.tlb -doc:"This is an ABAP test" -name:ABAPTest
    and register this WSC with a right mouse click on it and choose the
    menu item Register.

  <component id="ABAPTest">
    <?component error="true" debug="true"?>

      classid="{cfda20a9-a891-486d-89b7-9e57d1c91e75}" />

      <property name="MsgText">
      <method name="ShowMsgBox">
        <parameter name="AddMsgText"/>
      <property name="AlertText">
      <method name="ShowAlertBox">
        <parameter name="AddAlertText"/>

    <script language="VBScript">

    Dim MsgText

    Function get_MsgText()
      get_MsgText = MsgText
    End Function

    Function put_MsgText(newValue)
      MsgText = newValue
    End Function

    Sub ShowMsgBox(AddMsgText)
      MsgBox MsgText & vbCrLf & AddMsgText
    End Sub

    MsgText = "Hello World from WSC VBScript"


    <script language="JScript">

    var AlertText;

    function get_AlertText() {
      return AlertText;

    function put_AlertText(newValue) {
      AlertText = newValue;

    function ShowAlertBox(AddAlertText) {
      ShowMsgBox(AlertText + '\r' + AddAlertText)

    AlertText = 'Hello World from WSC JScript';




Compile this WSC file with the command rundll32 scrobj.dll,GenerateTypeLib ABAPTest.wsc -file:ABAPTest.tlb -doc:”This is an ABAP test” -name:ABAPTest to a type libaray and register the WSC file with the context menu item “Register”. Be sure that you have admin rights to register the WSC.


That is all, now we can use this componenten inside any other language. Here the VBScript example:


    Dim ABAPTest

    Set ABAPTest = CreateObject("ABAPTest.WSC")
    If IsObject(ABAPTest) Then

        ABAPTest.ShowMsgBox("This is a Test")

        ABAPTest.MsgText = "Hello World from ABAP via VBScript"
        ABAPTest.ShowMsgBox("This is another Test")

        MsgBox ABAPTest.MsgText

        ABAPTest.MsgText = vbNullString
        ABAPTest.ShowAlertBox("This is a Test")

        ABAPTest.AlertText = "Hello World from ABAP via JScript"
        ABAPTest.ShowAlertBox("This is another Test")

        MsgBox ABAPTest.AlertText

      Set ABAPTest = Nothing
    End If



And here the same example in ABAP:

  Report zWSCTest.

    "-Type pools--------------------------------------------------------
      Type-Pools OLE2.

      Data ABAPTest Type OLE2_OBJECT.
      Data MsgText Type String.
      Data AlertText Type String.

      Create Object ABAPTest 'ABAPTest.WSC'.
      If sy-subrc <> 0 Or ABAPTest-HANDLE = 0 Or
        ABAPTest-TYPE <> 'OLE2'.

        Call Method Of ABAPTest 'ShowMsgBox'
          Exporting #1 = 'This is a test'.

        Set Property Of ABAPTest 'MsgText' =
          'Hello World from ABAP via VBScript'.
        Call Method Of ABAPTest 'ShowMsgBox'
          Exporting #1 = 'This is another test'.

        Get Property Of ABAPTest 'MsgText' = MsgText.
        Write: / MsgText.

        Set Property Of ABAPTest 'MsgText' = ''.
        Call Method Of ABAPTest 'ShowAlertBox'
          Exporting #1 = 'This is a test'.

        Set Property Of ABAPTest 'AlertText' =
          'Hello World from ABAP via JScript'.
        Call Method Of ABAPTest 'ShowAlertBox'
          Exporting #1 = 'This is another test'.

        Get Property Of ABAPTest 'AlertText' = AlertText.
        Write: / AlertText.

      Free Object ABAPTest.



If you want to use a WSC on a Windows 64bit system, you must add the CLSID registration from HKCR\CLSID also to HKCR\Wow6432Node\CLSID.

Windows Registry Editor Version 5.00







With this option it is very easy to make functions of different scripting engines available in ABAP.


To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply