on 05-27-2015 12:09 PM
Hi,
I'm wondering if anyone can share vb script to close all active SAP if any. And then another one that will close the SAP app if it is running.
Thanks.
thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Brit,
this question would be better placed in Scripting Languages. But I did read it anyway.
You could try the following:
for example:
PATH = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\saplogon.exe"
on error resume next
Set SapGuiAuto = GetObject("SAPGUI")
if err.number <> 0 then
msgbox " 'SAP Logon' is not active.", vbInformation, "Information"
else
on error goto 0
Set application = SapGuiAuto.GetScriptingEngine
on error resume next
Set connection = application.Children(0)
if err.number <> 0 then
msgbox " No SAP - Session is active.", vbInformation, "Information"
else
on error goto 0
while connection.children.count > 0
Set session = connection.Children(0)
session.findbyid("wnd[0]").close
on error resume next
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
on error goto 0
wend
end if
set wshell = createObject("Wscript.Shell")
wshell.run chr(34) & PATH & chr(34)
wscript.Sleep 500
bWindowFound = Wshell.AppActivate("SAP Logon")
if bWindowFound then
Wshell.appActivate "SAP Logon"
WScript.Sleep 200
Wshell.sendkeys "%{F4}"
WScript.Sleep 200
end if
end if
Of course there are many other solutions that are much more elegant.
Regards,
ScriptMan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.