'------------------------------------------------------------------------------- ' Script : GetSapClientVersion.vbs ' Title : Get current versions of installed SAP components ' Assumptions : None ' Purpose : Read the version of SAP component installed. The versions ' are saved into the registry and the SAP_CLIENT.nnn file ' Contact persons : CLAUS Stéphane ' Further doc : ' Remarks : Use at your own risks '------------------------------------------------------------------------------- ' Author : CLAUS Stéphane ' Date : 16.08.2022 '------------------------------------------------------------------------------- ' M O D I F I C A T I O N S '------------------------------------------------------------------------------- ' Global constants Const APPLICATION = "SAP Client" Const SUB_APPLICATION = "Versions" Const COMPANY = "ACME" ' Directories and files Const SAP_64_DIR = "C:\Program Files\SAP\" Const SAP_32_DIR = "C:\Program Files (x86)\SAP\" Const VERSIONS_FILE = "SapClientVersion.ini" Const LOG_DIR = "c:\Logs" Const LOG_FILE = "SAP_Client_GetInstalledVersions.log" ' File access Const FOR_APPENDING = 8 ' Registry path Const REG_SEP = "\" Const NOT_INSTALLED = "*** NOT INSTALLED ***" Const NOT_FOUND = "*** NOT FOUND ***" Const UNKNOWN_VERSION = "Unknown version" ' Global constants (defined as variables) Dim strScrLogFile, strRegAppVersionsKey REG_VERSION_KEY = "HKLM\SOFTWARE" & REG_SEP & COMPANY & REG_SEP & "Computer Installed Software" strScrLogFile = LOG_DIR & REG_SEP & APPLICATION & " " & SUB_APPLICATION & ".log" strRegAppVersionsKey = REG_VERSION_KEY & REG_SEP & APPLICATION ' Global variables Dim strScriptPath, strScriptName, strCurPath, strVersionsFile Dim strComponent, strFullPath, strFile, strPath, strPath32, strPath64 Dim iVersionSAPCLIENT, strVersion, strVersionIni, strVersionDescription, strMajVersion, strRegPath Dim ZZ_MajVersion, ZZ_MinVersion ' Global objects Dim objShell, objReg, objFs, objMD5 Set objShell = WScript.CreateObject("WScript.Shell") Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") Set objFs = CreateObject("Scripting.FileSystemObject") Set objMD5 = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider") ' Retrieve current directory strScriptPath=Wscript.ScriptFullName strScriptName=Wscript.ScriptName strCurPath= Left(strScriptPath, Len(strScriptPath)-Len(strScriptName)) If Right(strCurPath,1)<> "\" Then strCurPath=strCurPath & "\" strVersionsFile=strCurPath & VERSIONS_FILE ' We need admin rights to execute this script RequireAdmin ' Directory for log file If Not objFs.FolderExists(LOG_DIR) Then objFs.CreateFolder(LOG_DIR) End If ' Delete log file if exists If objFS.FileExists(strScrLogFile) Then objFS.DeleteFile(strScrLogFile) End If ' ============================================================================== ' GET VERSIONS ================================================================= ' ============================================================================== WriteLogSeparator("") strComponent = "SAP Setup" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapSetup RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "NwSapSetup.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "NwSapSetup.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "NwSapSetup.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "Business Explorer" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapBI RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "BI\BExAnalyzer.exe" If objFs.FileExists(strFile) Then RegSaveVersion strPath & "BI\BExAnalyzer.exe", "True" Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "BExAnalyzer.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP GUI for Windows" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapGui RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "saplogon.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) iVersionSAPCLIENT = GetSAPClientVersion(strVersion) strVersionDescription = ReadIni(strVersionsFile, "saplogon.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "saplogon.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP NetWeaver Business Client 4" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapNWBC40 RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "NWBC.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "NWBC.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "NWBC.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP NetWeaver Business Client 5" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapNWBC50 RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "NWBC.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "NWBC.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "NWBC.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP Business Client 6" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapNWBC60 RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "NWBC.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "NWBC.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "NWBC.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP Business Client 6.5" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapNWBC65 RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "NWBC.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "NWBC.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "NWBC.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP Business Client 7.0" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapNWBC70 RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "NWBC.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "NWBC.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "NWBC.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP Business Client 7.7" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapNWBC77 RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "NWBC.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "NWBC.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "NWBC.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP 3D Visual Entreprise Viewer" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSap3DVEV RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "VEViewer.exe" If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "VEViewer.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SAP Secure Login Client" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath32 = GetPathSapSLC32 RegWrite strRegPath, "Path", "REG_SZ", strPath32 strPath64 = GetPathSapSLC64 RegWrite strRegPath, "Path64", "REG_SZ", strPath64 strFile = strPath32 & "bin\sbus.exe" If objFs.FileExists(strFile) Then RegSaveVersion strPath32 & "bin\sbus.exe", "True" strVersion = GetFileVersion(strPath32 & "bin\sbus.exe") strVersionDescription = ReadIni(strVersionsFile, "sbus.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersion & strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "sbus.exe", "REG_SZ", NOT_FOUND End If ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "Kerberos DLL" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent RegWrite strRegPath, "Path64", "REG_SZ", "C:\Program Files\SAP\Kerberos\" RegSaveVersion "C:\Program Files\SAP\Kerberos\gi64krb5.dll", "False" RegWrite strRegPath, "Path", "REG_SZ", "C:\Program Files (x86)\SAP\Kerberos\" RegSaveVersion "C:\Program Files (x86)\SAP\Kerberos\gsskrb5.dll", "True" ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "SBOP Analysis MS Office" WriteLog(strComponent) WriteLogSeparator("-") strRegAppVersionsKey = REG_VERSION_KEY & REG_SEP & APPLICATION_ANALYSIS strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapSBOP strFile = strPath & "BiOfficeLauncher.exe" RegWrite strRegPath, "Path", "REG_SZ", strPath If objFs.FileExists(strFile) Then RegSaveVersion strFile, "True" strVersion = GetFileVersion(strFile) strVersionDescription = ReadIni(strVersionsFile, "BiOfficeLauncher.exe", strVersion) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "BiOfficeLauncher.exe", "REG_SZ", NOT_FOUND End If strRegAppVersionsKey = REG_VERSION_KEY & REG_SEP & APPLICATION ' ------------------------------------------------------------------------------ WriteLogSeparator("") strComponent = "Engineering Client Viewer" WriteLog(strComponent) WriteLogSeparator("-") strRegPath = strRegAppVersionsKey & REG_SEP & strComponent strPath = GetPathSapECL RegWrite strRegPath, "Path", "REG_SZ", strPath strFile = strPath & "Program\WebViewer2D.dll" If objFs.FileExists(strFile) Then RegSaveVersion strPath & "Program\WebViewer2D.dll", "True" md5 = GetMd5( strFile ) strVersionDescription = ReadIni(strVersionsFile, "WebViewer2D.dll", md5) RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersionDescription WriteLog(strComponent & " " & strVersion & " (" & strVersionDescription & ")") Else RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", NOT_INSTALLED RegWrite strRegPath, "WebViewer2D.dll", "REG_SZ", NOT_FOUND End If ' ============================================================================== ' CREATE CHECK FILE ============================================================ ' ============================================================================== WriteLogSeparator("") WriteLog("Check file") WriteLogSeparator("-") CreateCheckFile ' ============================================================================== ' SUB FUNCTIONS ================================================================ ' ============================================================================== Function RequireAdmin() Dim reg_valuename, WShell, Cmd, CmdLine, I GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")_ .EnumValues &H80000003, "S-1-5-19\Environment", reg_valuename If IsArray(reg_valuename) <> 0 Then RequireAdmin = 1 Exit Function End If Set Cmd = WScript.Arguments For I = 0 to Cmd.Count - 1 If Cmd(I) = "/admin" Then Wscript.Echo "To script you must have administrator rights!" 'RequireAdmin = 0 'Exit Function WScript.Quit End If CmdLine = CmdLine & Chr(32) & Chr(34) & Cmd(I) & Chr(34) Next CmdLine = CmdLine & Chr(32) & Chr(34) & "/admin" & Chr(34) Set WShell= WScript.CreateObject( "WScript.Shell") CreateObject("Shell.Application").ShellExecute WShell.ExpandEnvironmentStrings(_ "%SystemRoot%\System32\WScript.exe"),Chr(34) & WScript.ScriptFullName & Chr(34) & CmdLine, "", "runas" WScript.Quit End Function Function GetMd5(filename) Dim oXml, oElement objMD5.ComputeHash_2(GetBinaryFile(filename)) Set oXml = CreateObject("MSXML2.DOMDocument") Set oElement = oXml.CreateElement("tmp") oElement.DataType = "bin.hex" oElement.NodeTypedValue = objMD5.Hash GetMd5 = oElement.Text End Function Function GetBinaryFile(filename) Dim oStream: Set oStream = CreateObject("ADODB.Stream") oStream.Type = 1 'adTypeBinary oStream.Open oStream.LoadFromFile filename GetBinaryFile= oStream.Read oStream.Close Set oStream = Nothing End Function Function ReadIni( myFilePath, mySection, myKey ) ' This function returns a value read from an INI file ' Source: https://www.robvanderwoude.com/vbstech_files_ini.php ' Written by Keith Lacelle ' Modified by Denis St-Pierre and Rob van der Woude Const ForReading = 1 Const ForWriting = 2 Const ForAppending = 8 Dim intEqualPos Dim objFSO, objIniFile Dim strFilePath, strKey, strLeftString, strLine, strSection Set objFSO = CreateObject( "Scripting.FileSystemObject" ) ReadIni = "" strFilePath = Trim( myFilePath ) strSection = Trim( mySection ) strKey = Trim( myKey ) If objFSO.FileExists( strFilePath ) Then Set objIniFile = objFSO.OpenTextFile( strFilePath, ForReading, False ) Do While objIniFile.AtEndOfStream = False strLine = Trim( objIniFile.ReadLine ) ' Check if section is found in the current line If LCase( strLine ) = "[" & LCase( strSection ) & "]" Then strLine = Trim( objIniFile.ReadLine ) ' Parse lines until the next section is reached Do While Left( strLine, 1 ) <> "[" ' Find position of equal sign in the line intEqualPos = InStr( 1, strLine, "=", 1 ) If intEqualPos > 0 Then strLeftString = Trim( Left( strLine, intEqualPos - 1 ) ) ' Check if item is found in the current line If LCase( strLeftString ) = LCase( strKey ) Then ReadIni = Trim( Mid( strLine, intEqualPos + 1 ) ) ' In case the item exists but value is blank If ReadIni = "" Then ReadIni = " " End If ' Abort loop when item is found Exit Do End If End If ' Abort if the end of the INI file is reached If objIniFile.AtEndOfStream Then Exit Do ' Continue with next line strLine = Trim( objIniFile.ReadLine ) Loop Exit Do End If Loop objIniFile.Close Else WScript.Echo strFilePath & " doesn't exists. Exiting..." WScript.Quit 1 End If End Function Function WriteLog(pLog) ' Add an entry in the log file. Each entry is prefixed with a timestamp dim strLog strLog = Now() strLog = strLog & " - " & pLog Set objTextFile = objFs.OpenTextFile(strScrLogFile, FOR_APPENDING, True) objTextFile.WriteLine(strLog) objTextFile.Close Set objTextFile = Nothing End Function Function WriteLogSeparator(pSep) ' Add a separator into the log If pSep = "-" Then WriteLog("--------------------------------------------------------------------------------") ElseIf pSep = "=" Then WriteLog("================================================================================") ElseIf pSep = "*" Then WriteLog("********************************************************************************") Else WriteLog("") End If End Function Function GetFileVersion(pFile) If objFs.FileExists(pFile) Then strVersion = objFs.GetFileVersion(pFile) Else strVersion = NOT_FOUND End If GetFileVersion=strVersion End Function Sub RegSaveVersion(pFile, pComponentVersion) Dim strFile, strInstr64, strInstr32 strVersion=GetFileVersion(pFile) strFile = objFs.GetFileName(pFile) strInstr64=InStr(pFile,":\Program Files\") strInstr32=InStr(pFile,":\Program Files (x86)\") If ( strInstr32 = 0 ) And ( strInstr64 <> 0 ) Then ' 64 bits strFile = strFile & " (64)" End If RegWrite strRegPath, strFile, "REG_SZ", strVersion If pComponentVersion = "True" Then RegWrite strRegAppVersionsKey, strComponent, "REG_SZ", strVersion WriteLog strComponent & " => " & strVersion End If WriteLog objFs.GetFileName(pFile) & " -> " & strVersion End Sub Function GetSAPClientVersion(pSapLogonVersion) Dim strInstr, strLeft If pSapLogonVersion = NOT_INSTALLED Then GetSAPClientVersion = 000 Else strInstr=InStr(pSapLogonVersion,".") If strInstr > 0 Then strLeft = left( pSapLogonVersion, strInstr-2 ) GetSAPClientVersion = strLeft Else GetSAPClientVersion = 000 End If End If End Function ' Bitwise left shift Function Lsh(ByVal N, ByVal Bits) Lsh = N * (2 ^ Bits) End Function Function GetVersionStringAsArray(ByVal Version) Dim VersionAll, VersionParts, N VersionAll = Array(0, 0, 0, 0) VersionParts = Split(Version, ".") For N = 0 To UBound(VersionParts) VersionAll(N) = CLng(VersionParts(N)) Next Dim Hi, Lo Hi = Lsh(VersionAll(0), 16) + VersionAll(1) Lo = Lsh(VersionAll(2), 16) + VersionAll(3) GetVersionStringAsArray = Array(Hi, Lo) End Function Sub CreateCheckFile Dim iVersion, strCheckFile, strDstFile ' Remove previous check file iVersion = 000 strCheckFile = SAP_32_DIR & APPLICATION strSrcFile = strCheckFile & "." & iVersion If objFs.FileExists( strSrcFile ) Then WriteLog( "Delete check file '" & strSrcFile & "'" ) objFs.DeleteFile( strSrcFile ) End If strCheckFile = SAP_64_DIR & APPLICATION strSrcFile = strCheckFile & "." & iVersion If objFs.FileExists( strSrcFile ) Then WriteLog( "Delete check file '" & strSrcFile & "'" ) objFs.DeleteFile( strSrcFile ) End If For iVersion = 600 to 900 strCheckFile = SAP_32_DIR & APPLICATION strSrcFile = strCheckFile & "." & iVersion If objFs.FileExists( strSrcFile ) Then WriteLog( "Delete check file '" & strSrcFile & "'" ) objFs.DeleteFile( strSrcFile ) End If strCheckFile = SAP_64_DIR & APPLICATION strSrcFile = strCheckFile & "." & iVersion If objFs.FileExists( strSrcFile ) Then WriteLog( "Delete check file '" & strSrcFile & "'" ) objFs.DeleteFile( strSrcFile ) End If Next ' Copy log file to Check file If iVersionSAPCLIENT > 0 Then If objFS.FolderExists(SAP_32_DIR) Then strSrcFile = strScrLogFile strDstFile = SAP_32_DIR & APPLICATION & "." & iVersionSAPCLIENT WriteLog( "Copy this log to '" & strDstFile & "'" ) objFs.CopyFile strSrcFile, strDstFile, True End If ' Copy log file to Check file If objFS.FolderExists(SAP_64_DIR) Then strDstFile = SAP_64_DIR & APPLICATION & "." & iVersionSAPCLIENT WriteLog( "Copy this log to '" & strDstFile & "'" ) objFs.CopyFile strSrcFile, strDstFile, True End If ' Remove log file If (objFS.FolderExists(SAP_32_DIR)) or (objFS.FolderExists(SAP_64_DIR)) Then objFs.DeleteFile( strSrcFile ) End If End If End Sub Function RegWrite(reg_keyname, reg_valuename,reg_type,ByVal reg_value) Dim aRegKey, Return aRegKey = RegSplitKey(reg_keyname) If IsArray(aRegKey) = 0 Then RegWrite = 0 Exit Function End If Return = RegWriteKey(aRegKey) If Return = 0 Then RegWrite = 0 Exit Function End If Select Case reg_type Case "REG_SZ" Return = objReg.SetStringValue(aRegKey(0),aRegKey(1),reg_valuename,reg_value) Case "REG_EXPAND_SZ" Return = objReg.SetExpandedStringValue(aRegKey(0),aRegKey(1),reg_valuename,reg_value) Case "REG_BINARY" If IsArray(reg_value) = 0 Then reg_value = Array() Return = objReg.SetBinaryValue(aRegKey(0),aRegKey(1),reg_valuename,reg_value) Case "REG_DWORD" If IsNumeric(reg_value) = 0 Then reg_value = 0 Return = objReg.SetDWORDValue(aRegKey(0),aRegKey(1),reg_valuename,reg_value) Case "REG_MULTI_SZ" If IsArray(reg_value) = 0 Then If Len(reg_value) = 0 Then reg_value = Array() Else reg_value = Array(reg_value) End If End If Return = objReg.SetMultiStringValue(aRegKey(0),aRegKey(1),reg_valuename,reg_value) ' Case "REG_QWORD" ' Return = oReg.SetQWORDValue(aRegKey(0),aRegKey(1),reg_valuename,reg_value) Case Else RegWrite = 0 Exit Function End Select If (Return <> 0) Or (Err.Number <> 0) Then RegWrite = 0 Exit Function End If RegWrite = 1 End Function Function RegWriteKey(RegKeyName) Dim Return If IsArray(RegKeyName) = 0 Then RegKeyName = RegSplitKey(RegKeyName) End If If (IsArray(RegKeyName) = 0) Or (UBound(RegKeyName) <> 1) Then RegWriteKey = 0 Exit Function End If Return = objReg.CreateKey(RegKeyName(0),RegKeyName(1)) If (Return <> 0) Or (Err.Number <> 0) Then RegWriteKey = 0 Exit Function End If RegWriteKey = 1 End Function Function RegSplitKey(RegKeyName) Dim strHive, strInstr, strLeft strInstr=InStr(RegKeyName,"\") If strInstr = 0 Then Exit Function strLeft=left(RegKeyName,strInstr-1) Select Case strLeft Case "HKCR","HKEY_CLASSES_ROOT" strHive = &H80000000 Case "HKCU","HKEY_CURRENT_USER" strHive = &H80000001 Case "HKLM","HKEY_LOCAL_MACHINE" strHive = &H80000002 Case "HKU","HKEY_USERS" strHive = &H80000003 Case "HKCC","HKEY_CURRENT_CONFIG" strHive = &H80000005 Case Else Exit Function End Select RegSplitKey = Array(strHive,Mid(RegKeyName,strInstr+1)) End Function Function RegDelete(reg_keyname, reg_valuename) Dim Return,aRegKey aRegKey = RegSplitKey(reg_keyname) If IsArray(aRegKey) = 0 Then RegDelete = 0 Exit Function End If Return = objReg.DeleteValue(aRegKey(0),aRegKey(1),reg_valuename) If (Return <> 0) And (Err.Number <> 0) Then RegDelete = 0 Exit Function End If RegDelete = 1 End Function Function RegCheckKeyExists(strRegKey) RegCheckKeyExists = False Dim strRegKey2 On Error Resume Next strRegKey2 = objShell.RegRead(strRegKey) If Err <> 0 Then RegCheckKeyExists = False Else RegCheckKeyExists = True End If On Error GoTo 0 End Function Function GetPathSapSetup Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAPSetupDir" If RegCheckKeyExists(lRegKey) Then GetPathSapSetup = objShell.RegRead(lRegKey) Else GetPathSapSetup = "c:\Program Files (x86)\SAP\SapSetup\" End If If Right(GetPathSapSetup, 1) <> "\" Then GetPathSapSetup = GetPathSapSetup & "\" GetPathSapSetup = GetPathSapSetup & "setup\" End Function Function GetPathSapGui Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAPsysdir" If RegCheckKeyExists(lRegKey) Then GetPathSapGui = objShell.RegRead(lRegKey) Else GetPathSapGui = "c:\Program Files (x86)\SAP\FrontEnd\SapGui" End If If Right(GetPathSapGui, 1) <> "\" Then GetPathSapGui = GetPathSapGui & "\" End Function Function GetPathSapBI Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAPBI\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapBI = objShell.RegRead(lRegKey) Else GetPathSapBI = "c:\Program Files (x86)\SAP\Business Explorer" End If If Right(GetPathSapBI, 1) <> "\" Then GetPathSapBI = GetPathSapBI & "\" End Function Function GetPathSapNWBC40 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAP_NWBC40\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapNWBC40 = objShell.RegRead(lRegKey) Else GetPathSapNWBC40 = "c:\Program Files (x86)\SAP\NWBC40" End If If Right(GetPathSapNWBC40, 1) <> "\" Then GetPathSapNWBC40 = GetPathSapNWBC40 & "\" End Function Function GetPathSapNWBC50 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAP_NWBC50\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapNWBC50 = objShell.RegRead(lRegKey) Else GetPathSapNWBC50 = "c:\Program Files (x86)\SAP\NWBC50" End If If Right(GetPathSapNWBC50, 1) <> "\" Then GetPathSapNWBC50 = GetPathSapNWBC50 & "\" End Function Function GetPathSapNWBC60 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAP_NWBC60\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapNWBC60 = objShell.RegRead(lRegKey) Else GetPathSapNWBC60 = "c:\Program Files (x86)\SAP\NWBC60" End If If Right(GetPathSapNWBC60, 1) <> "\" Then GetPathSapNWBC60 = GetPathSapNWBC60 & "\" End Function Function GetPathSapNWBC65 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAP_NWBC65\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapNWBC65 = objShell.RegRead(lRegKey) Else GetPathSapNWBC65 = "c:\Program Files (x86)\SAP\NWBC65" End If If Right(GetPathSapNWBC65, 1) <> "\" Then GetPathSapNWBC65 = GetPathSapNWBC65 & "\" End Function Function GetPathSapNWBC70 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAP_NWBC70\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapNWBC70 = objShell.RegRead(lRegKey) Else GetPathSapNWBC70 = "c:\Program Files (x86)\SAP\NWBC70" End If If Right(GetPathSapNWBC70, 1) <> "\" Then GetPathSapNWBC70 = GetPathSapNWBC70 & "\" End Function Function GetPathSapNWBC77 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAP_NWBC77\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapNWBC77 = objShell.RegRead(lRegKey) Else GetPathSapNWBC77 = "c:\Program Files (x86)\SAP\NWBC77" End If If Right(GetPathSapNWBC77, 1) <> "\" Then GetPathSapNWBC77 = GetPathSapNWBC77 & "\" End Function Function GetPathSap3DVEV Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP 3D Visual Enterprise Viewer\Path" If RegCheckKeyExists(lRegKey) Then GetPathSap3DVEV = objShell.RegRead(lRegKey) Else GetPathSap3DVEV = "c:\Program Files (x86)\SAP\SAP 3D Visual Enterprise Viewer" End If If Right(GetPathSap3DVEV, 1) <> "\" Then GetPathSap3DVEV = GetPathSap3DVEV & "\" End Function Function GetPathSapECL Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAP_Engineering Client Viewer 7.0\SAPDestDir" If RegCheckKeyExists(lRegKey) Then GetPathSapECL = objShell.RegRead(lRegKey) Else lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SAP Shared\SAPsysdir" If RegCheckKeyExists(lRegKey) Then GetPathSapECL = objShell.RegRead(lRegKey) Else GetPathSapECL = "c:\Program Files (x86)\SAP\FrontEnd\SapGui" End If End If If GetPathSapECL = "" Then GetPathSapECL = GetPathSapGui If Right(GetPathSapECL, 1) <> "\" Then GetPathSapECL = GetPathSapECL & "\" End Function Function GetPathSapSLC32 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SecureLogin\InstallPath32" If RegCheckKeyExists(lRegKey) Then GetPathSapSLC32 = objShell.RegRead(lRegKey) Else GetPathSapSLC32 = "c:\Program Files (x86)\SAP\FrontEnd\SecureLogin" End If If Right(GetPathSapSLC32, 1) <> "\" Then GetPathSapSLC32 = GetPathSapSLC32 & "\" End Function Function GetPathSapSLC64 Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\SecureLogin\InstallPath64" If RegCheckKeyExists(lRegKey) Then GetPathSapSLC64 = objShell.RegRead(lRegKey) Else GetPathSapSLC64 = "c:\Program Files\SAP\FrontEnd\SecureLogin" End If If Right(GetPathSapSLC64, 1) <> "\" Then GetPathSapSLC64 = GetPathSapSLC64 & "\" End Function Function GetPathSapSBOP Dim lRegKey lRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\SAP\CommonOfficeFramework\InstallPath" If RegCheckKeyExists(lRegKey) Then GetPathSapSBOP = objShell.RegRead(lRegKey) Else GetPathSapSBOP = "c:\Program Files (x86)\SAP BusinessObjects\Office AddIn" End If If Right(GetPathSapSBOP, 1) <> "\" Then GetPathSapSBOP = GetPathSapSBOP & "\" End Function Function GetSBOPAnalysisVersion(pSBOPVersion) Dim strInstr, strLeft, lstrVersion lstrVersion = pSBOPVersion WriteLog(lstrVersion) If lstrVersion = NOT_INSTALLED Then GetSBOPAnalysisVersion = 000 Else strInstr=InStr(lstrVersion,".") If strInstr > 0 Then strLeft = left( lstrVersion, strInstr ) strLeft = strLeft * 10 WriteLog(strLeft) GetSBOPAnalysisVersion = strLeft lstrVersion = mid(lstrVersion, strInstr + 1) strInstr=InStr(lstrVersion,".") If strInstr > 0 Then strLeft = left( lstrVersion, strInstr ) strLeft = strLeft * 10 GetSBOPAnalysisVersion = GetSBOPAnalysisVersion + strLeft End If Else GetSBOPAnalysisVersion = 000 End If End If End Function