Skip to Content

Hello community,

AutoIt is an incredible scripting language, it offers so much possibilities, e.g. to control processes and windows. Here now an example how to restart the SAPLogon on the fly:

;-Begin-----------------------------------------------------------------
 

  ;-Sub RestartProcess--------------------------------------------------
    Func RestartProcess($ProcessName)

      $PID = ProcessExists($ProcessName)
      If $PID Then

        $oWMI = ObjGet("winmgmts:\\.\root\CIMV2")
        If IsObj($oWMI) Then
          $Process = $oWMI.ExecQuery("Select * From win32_process " & _
            "Where Name = '" & $ProcessName & "'")
          If IsObj($Process) Then
            $ProcessPath = $Process.ItemIndex(0).ExecutablePath
          EndIf
        EndIf

        ProcessClose($PID)
        ProcessWait($PID)

        Run($ProcessPath)

      EndIf

    EndFunc

  ;-Sub Main------------------------------------------------------------
    Func Main()

      RestartProcess("saplogon.exe")
      WinWait("SAP Logon ")
      Sleep(4096)

    EndFunc

  ;-Main----------------------------------------------------------------
    Main()

;-End-------------------------------------------------------------------

As you can see it is absolut easy to get the process ID (PID), to close the process and to restart the process – here with the aid of Windows Management Instrumentarium (WMI).

Important hint: This script closes and restarts the saplogon process immediately, without any requests – all changes will be lost.

This script is excellent for stray processes on the frontend server.

Enjoy it.

Cheers
Stefan

To report this post you need to login first.

1 Comment

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

  1. Jeremy Mathy

    Excellent tip!  I use AutoIt to write SAPGUI install packages.  I can use this technique to help ensure the Logon Pad is fully closed prior to kicking off NWSapSetup.

    Cheers!

    Jeremy

    (0) 

Leave a Reply