cancel
Showing results for 
Search instead for 
Did you mean: 

SAP GUI stop scripting

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

stefan_schnell
Active Contributor
0 Kudos

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

Answers (1)

Answers (1)

Former Member
0 Kudos


Excellent got it. Thank you for you help