Tutorial: How To Get Settings From SAP GUI Scripting

If you work with SAP GUI Scripting it is sometimes good to know the user settings of the SAP Logon in the context with UiPath.

sapguiscripting001

The user settings are stored in the Windows Registry. You can find more information here in the SAP GUI for Windows Administration Guide.

I developed a tiny invoke code routine to get all this settings.

'-Begin-----------------------------------------------------------------

Try

  Dim Key As String = "Software\SAP\SAPGUI Front\SAP Frontend Server\Security"

  Dim regKey As Microsoft.Win32.RegistryKey
  regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Key)
  If regKey Is Nothing Then
    UserScripting = 1    'Deliver default
    WarnOnAttach = 1     'Deliver default
    WarnOnConnection = 1 'Deliver default
    ErrorRet = "Security key not exists"
  Else	

    Dim oUserScripting As Object = regKey.GetValue("UserScripting")
    If oUserScripting Is Nothing Then
      UserScripting = 1
    Else
      UserScripting = CInt(oUserScripting)
    End If

    Dim oWarnOnAttach As Object = regKey.GetValue("WarnOnAttach")
    If oWarnOnAttach Is Nothing Then
      WarnOnAttach = 1
    Else
      WarnOnAttach = CInt(oWarnOnAttach)
    End If

    Dim oWarnOnConnection As Object = regKey.GetValue("WarnOnConnection")
    If oWarnOnConnection Is Nothing Then
      WarnOnConnection = 1
    Else
      WarnOnConnection = CInt(oWarnOnConnection)
    End If
	
  End If

  Key = "Software\SAP\SAPGUI Front\SAP Frontend Server\Scripting"

  regKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Key)
  If regKey Is Nothing Then
    ShowNativeWinDlgs = 0 'Deliver default
    If Not String.IsNullOrEmpty(ErrorRet) Then
      ErrorRet = ErrorRet + vbCrLf
    End If
    ErrorRet = ErrorRet + "Scripting key not exists"
  Else

    Dim oShowNativeWinDlgs As Object = regKey.GetValue("ShowNativeWinDlgs")
    If oShowNativeWinDlgs Is Nothing Then
      ShowNativeWinDlgs = 0
    Else
      ShowNativeWinDlgs = CInt(oShowNativeWinDlgs)
    End If

  End If

Catch ex As Exception
  ErrorRet = ex.Message
End Try
  
'-End-------------------------------------------------------------------

ReadSAPScriptingRegistryValues.xaml (7.4 KB)

Alternatively you can use the GUI Info for SAP Activity from the UiPath Marketplace.

4 Likes