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.