cancel
Showing results for 
Search instead for 
Did you mean: 

Automate SAP start and log in using VBScript

0 Kudos

Hello! I am creating a scritp to start SAP application via Windows Prompt, log into it and then start using a transaction. The steps are:

  1. Start SAP executable (saplgpad.exe).
  2. Open SAP ECC - PRD window (SID: EP0).
  3. Log in to my account.

However, I am having trouble when doing step 2. Could someone help me please?

Below is my code. I am using the following command do run the .vbs file: C:\Users\*******\AppData\Roaming\SAP\SAP GUI\Scripts>cscript ScriptName.vbs

Dim WSHShell, SAPGUIPath, Name, SID, InstanceNo, objapp, WinTitle

Set WSHShell = WScript.CreateObject("WScript.Shell")

If IsObject(WSHShell) Then
    SAPGUIPath = "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\"
    Name = """SAP ECC - PRD"""
    SID = "EP0"
    InstanceNo = "00"
    Set objapp = WSHShell.Exec SAPGUIPath & "saplgpad.exe " & Name & " " & InstanceNo
    WinTitle = "SAP"
    While Not WSHShell.AppActivate(WinTitle)
      WScript.Sleep 250
    Wend
    Set WSHShell = Nothing
End If

session.findById("wnd[0]").maximize
On Error Resume Next
session.findById("wnd[0]/usr/txtRSYST-MANDT").Text = "100"
On Error Resume Next
session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "*******"
On Error Resume Next
session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "*********"
On Error Resume Next
session.findById("wnd[0]/usr/txtRSYST-LANGU").Text = "PT"
On Error Resume Next
session.findById("wnd[0]").sendVKey 0<br>
former_member763929
Participant
0 Kudos

Thank you for visiting SAP Community to get answers to your questions. Since this is your first question, I recommend that you familiarize yourself with Community Q&A , as the overview provides tips for preparing questions that draw responses from our members.

Should you wish, you can revise your question by selecting Actions, then Edit

Accepted Solutions (0)

Answers (0)