Tutorial: Detect if SAP GUI is Installed and Which Version

In some cases it can be very helpful to know if the SAP GUI for Windows is installed on the machine and in which version it is available.

SAP%20GUI%20Version

SAP note 526199 delivers a tiny VBS file and on this base I realized an implementation in UiPath.

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

Dim SapDestDir As String
IsSAPGUIInstalled = False

Try

  Dim Key As String = "Software\SAP\SAP Shared"
  Dim Key64 As String = "Software\Wow6432Node\SAP\SAP Shared"

  Dim regKey As Microsoft.Win32.RegistryKey
  regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Key64)
  If regKey Is Nothing Then
    regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(Key)
  End If

  If regKey Is Nothing Then
    ErrorRet = "SAP Shared key not exists"
  Else

    Dim oSapDestDir As Object = regKey.GetValue("SapDestDir")
    If Not oSapDestDir Is Nothing Then
      SapDestDir = CStr(oSapDestDir)
    End If

    If Not String.IsNullOrEmpty(SapDestDir) Then
      If File.Exists(SapDestDir + "\SapGui\saplogon.exe") Then
        IsSAPGUIInstalled = True
        Dim SAPVers As System.Diagnostics.FileVersionInfo = _
          System.Diagnostics.FileVersionInfo.GetVersionInfo(SapDestDir + _
          "\SapGui\saplogon.exe")
        Version = SAPVers.FileVersion
        MajorVersion = SAPVers.FileMajorPart.ToString
        MinorVersion = SAPVers.FileMinorPart.ToString
        PatchLevel = SAPVers.FileBuildPart.ToString
      End If
    End If

  End If

Catch ex As Exception
  ErrorRet = ex.Message
End Try	

'-End-------------------------------------------------------------------

The only difference is, I choose saplogon.exe to get the version information. SAP uses sapgui.exe or sapfront.dll - but this is easy to change. :slightly_smiling_face:

IsSAPGUIInstalledVersion.xaml (7.0 KB)

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

8 Likes

Great work! I did a minor change in defining SapDestDir as returning Argument. Instead of “Dim” assign it to “” instead. So I can use the path instead a hardcoded one in my SAP startup with “\SapGui\sapshcut.exe”.

1 Like

@moenk

Hello Thomas,
thank you. Great idea and easy to realize :slightly_smiling_face:
Best regards
Stefan

1 Like