Before SAP Logon 740 version, we can enable SAP GUI to save password in GUI shortcut.
Yes, just enable it from Windows registry editor. By starting the program regedit.exe
HKEY_CURRENT_USER\Software\SAP\SAPShortcut\Security\EnablePassword
Since SAP GUI 750, for security reasons, SAP has disabled this remember features.
We can use VBS script to help us auto logon SAP.
'------------------------------------------------------------------
'- VBScript to start SAP Logon if process doesn't exists and connect
'- to an SAP system. The SAP Logon process is detected via WMI
'- (Windows Management Instrumentarium), also the termination.
'-----------------------------------------------------------------------
'-Directives----------------------------------------------------------
Option Explicit
'-Variables-----------------------------------------------------------
Dim SAPLogon, SAPLogonTitle
'Please change your SAPLogonTitle
SAPLogon = "saplogon.exe" : SAPLogonTitle = "SAP Logon 770"
Dim SysDescr, SysIP
'-----------------------------------------------------------------
'Sysdescr is the descripting in SAP GUI, or you cant use SysIP as connection string. Enable one.
'-----------------------------------------------------------------
'SysDescr = "xxxdev"
'SysIP = "/H/RouterIP/S/router port/H/application IP/S/port"
SysIP = "/M/messageserver/S/messageserver port/G/message group"
'-Function FindProcess------------------------------------------------
Function FindProcess(ProcessName)
'-Variables-------------------------------------------------------
Dim WMIServ, Processes, Process
FindProcess = False
Set WMIServ = GetObject("winmgmts:{impersonationLevel=" & _
"impersonate}!\\.\root\cimv2")
Set Processes = WMIServ.ExecQuery("Select * from Win32_Process " & _
"Where Name = '" & ProcessName & "'")
For Each Process In Processes
FindProcess = True
Exit Function
Next
End Function
'-Sub TerminateProcess------------------------------------------------
Sub TerminateProcess(ProcessName)
'-Variables-------------------------------------------------------
Dim WMIServ, Processes, Process
Set WMIServ = GetObject("winmgmts:{impersonationLevel=" & _
"impersonate}!\\.\root\cimv2")
Set Processes = WMIServ.ExecQuery("Select * from Win32_Process " & _
"Where Name = '" & ProcessName & "'")
For Each Process In Processes
Process.Terminate()
Exit Sub
Next
End Sub
'-Function GetSAPGUIObject--------------------------------------------
'- This function starts the SAP Logon if it is necessary and delivers
'- its object
'---------------------------------------------------------------------
Function GetSAPGUIObject()
'-Variables-------------------------------------------------------
Dim WshShell, Exec
If FindProcess(SAPLogon) Then
Set GetSAPGUIObject = GetObject("SAPGUI")
Else
Set WshShell = CreateObject("WScript.Shell")
Set Exec = WshShell.Exec(_
"c:\Program Files (x86)\SAP\FrontEnd\SAPgui\" & SAPLogon)
Do While Not WshShell.AppActivate(SAPLogonTitle)
WScript.Sleep 500
Loop
Set GetSAPGUIObject = GetObject("SAPGUI")
End If
End Function
'-Sub Main------------------------------------------------------------
Sub Main()
'-Variables-------------------------------------------------------
Dim SapGuiAuto, Application, Connection, Session
Set SapGuiAuto = GetSAPGUIObject()
If Not IsObject(SapGuiAuto) Then
Exit Sub
End If
Set Application = SapGuiAuto.GetScriptingEngine
If Not IsObject(Application) Then
Set SapGuiAuto = Nothing
Exit Sub
End If
'-----------------------------------------------------------------
'- You can choose user logon connection in SAP GUI or Connection String
'-----------------------------------------------------------------
'Set Connection = Application.OpenConnection(SysDescr, True)
Set Connection = Application.OpenConnectionByConnectionString( SysIP, True)
If Not IsObject(Connection) Then
Set Application = Nothing
Set SapGuiAuto = Nothing
Exit Sub
End If
Set Session = Connection.Children(0)
If Not IsObject(Session) Then
Set Connection = Nothing
Set Application = Nothing
Set SapGuiAuto = Nothing
Exit Sub
End If
MyScript(Session)
'Set Session = Nothing
'Set Connection = Nothing
'Set Application = Nothing
'Set SapGuiAuto = Nothing
'TerminateProcess SAPLogon
End Sub
'-Sub MyScript--------------------------------------------------------
Sub MyScript(Session)
'-----------------------------------------------------------------
'- Change your client, username and password
'-----------------------------------------------------------------
session.findById("wnd[0]").maximize
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "001"
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "username"
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "password"
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "EN"
session.findById("wnd[0]").sendVKey 0
End Sub
'-Main----------------------------------------------------------------
Main
Comments
Post a Comment