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 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.
IsSAPGUIInstalledVersion.xaml (7.0 KB)
Alternatively you can use the GUI Info for SAP Activity from the UiPath Marketplace.