Skip to Content
avatar image
Former Member

SAP GUI stop scripting

Hi,

I am struggling to stop the scripting engine in VB.NET I tried multiple ways to make the following code but nothing worked for me. Always the baber pole shows running on all the open sessions.

Sapguiauto = GetObject("SAPGUI")

sapapplication = sapguiauto.getscriptingengine

For Each Connection In SapApplication.Children

If Not Connection.DisabledByServer Then

For Each session In Connection.Children

ComboBox1.Items.Add(session.Info.SystemName + " (" + CStr(session.Info.SessionNumber) + ") (" + session.Info.Client + ")")

ListBox1.Items.Add(session.Id)

Next

End If

Next

sapguiauto = Nothing

Connection = Nothing

sapapplication = nothing

session = Nothing

Even though all the variables to nothing, still the barber pole shows running. I found only the way to close the exe application to stop it. Is there any way to stop it and start when we start recording.

Thanks

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 04, 2015 at 07:43 AM

    Hello Sampath,

    welcome to Scripting Language forum.

    Here a solution to stop the rotating barber pole, it is a simple VB.NET console application:

    '-Begin-----------------------------------------------------------------

    '-Directives----------------------------------------------------------

    Option Strict Off

    Option Explicit

    '-Imports-------------------------------------------------------------

    Imports System

    Imports System.Runtime.InteropServices

    Imports System.Threading

    '-Modules-------------------------------------------------------------

    Module ModuleMain

    Sub Main()

    '-Variables-----------------------------------------------------

    Dim SAPGUIAuto As Object

    Dim SAPApplication As Object

    Dim Connection As Object

    Dim Session As Object

    Dim OutText As String

    SAPGUIAuto = GetObject("SAPGUI")

    If IsReference(SAPGUIAuto) Then

    SAPApplication = SAPGUIAuto.GetScriptingEngine()

    If IsReference(SAPApplication) Then

    For Each Connection In SAPApplication.Children()

    For Each Session In Connection.Children()

    OutText = Session.Info.SystemName()

    OutText += " (" & CStr(Session.Info.SessionNumber()) & ")"

    OutText += " [" & Session.Info.Client() & "]"

    Console.WriteLine(OutText)

    Next

    Next

    End If

    End If

    '-Barber pole rotates-------------------------------------------

    Thread.Sleep(2048)

    '-Releases COM object-------------------------------------------

    Marshal.ReleaseComObject(SAPGUIAuto)

    GC.Collect()

    GC.WaitForPendingFinalizers()

    '-Barber pole now rotates not any longer------------------------

    Console.Write("Press enter to exit...")

    Console.ReadLine()

    End Sub

    End Module

    '-End-------------------------------------------------------------------

    Let us know your result

    Cheers

    Stefan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 04, 2015 at 09:09 PM


    Excellent got it. Thank you for you help

    Add comment
    10|10000 characters needed characters exceeded