Hi Norbert,
We now upgraded to R81.10, but it seems that the script isn't working anymore, any idea what i need to change except the path of smartconsole?
#AutoIt3Wrapper_UseX64=n
Opt("MustDeclareVars", 1)
AutoItSetOption("WinTitleMatchMode", 3) ; Exact title match
;==========================================================================
; PSM Universal Connector - Check Point SmartConsole Dispatcher
; -----------------------------------------
; Vendor: Check Point
; Product: SmartConsole
; Version: R80.30
; Creator: Norbert Bohusch, Bacher Systems EDV GmbH
;==========================================================================
#include "PSMGenericClientWrapper.au3"
#include <BlockInputEx.au3>
#include <File.au3>
#include "FileConstants.au3"
;=======================================
; Consts & Globals
;=======================================
Global Const $DISPATCHER_NAME = "Check Point SmartConsole"
Global Const $LOGIN_PARMS_FILE = "" & @TempDir & "\SmartConsole.LoginParams" & "" ; Temporary Login Parameters File in TEMP folder
Global Const $CLIENT_EXECUTABLE = """C:\Program Files (x86)\CheckPoint\SmartConsole\R81.10\PROGRAM\SmartConsole.exe"" -p " & $LOGIN_PARMS_FILE ; CHANGE_ME - change if installed in different path
Global Const $ERROR_MESSAGE_TITLE = "PSM " & $DISPATCHER_NAME & " Dispatcher error message"
Global Const $LOG_MESSAGE_PREFIX = $DISPATCHER_NAME & " Dispatcher - "
Global $TargetUsername ; Will be fetched from the PSM session
Global $TargetPassword ; Will be fetched from the PSM session
Global $TargetAddress ; Will be fetched from the PSM session
Global $TargetDomain ; Will be fetched from the PSM session
Global $ConnectionClientPID = 0
Global Const $sleep = 1000
;=======================================
; Code
;=======================================
Exit Main()
;=======================================
; Main
;=======================================
Func Main()
; Init PSM Dispatcher utils wrapper
ToolTip ("Initializing...")
if (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
LogWrite("successfully initialized Dispatcher Utils Wrapper")
; Get the dispatcher parameters
FetchSessionProperties()
_BlockInputEx(1) ; Block all
; Write Login Parameter File
ToolTip ("Writing login parameter file...")
Local Const $hFile = FileOpen($LOGIN_PARMS_FILE, $FO_OVERWRITE)
;LogWrite("Opened File: " & $LOGIN_PARMS_FILE)
LogWrite("writing login parameter file")
FileWrite($hFile, "<?xml version=""1.0"" encoding=""utf-8""?>" & @CRLF)
FileWrite($hFile, "<RemoteLaunchParemeters xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">" & @CRLF)
FileWrite($hFile, "<Username>" & $TargetUsername & "</Username>" & @CRLF)
FileWrite($hFile, "<ServerIP>" & $TargetAddress & "</ServerIP>" & @CRLF)
FileWrite($hFile, "<Password>" & $TargetPassword & "</Password>" & @CRLF)
FileWrite($hFile, "<DomainName>" & $TargetDomain & "</DomainName>" & @CRLF)
FileWrite($hFile, "</RemoteLaunchParemeters>")
FileClose($hFile)
; Run exe and activate
LogWrite("starting client application: " & $CLIENT_EXECUTABLE)
ToolTip ("Starting " & $DISPATCHER_NAME & "...")
$ConnectionClientPID = Run($CLIENT_EXECUTABLE, "", @SW_MAXIMIZE)
If ($ConnectionClientPID == 0) Then
Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))
EndIf
LoginProcess()
_BlockInputEx(0) ; Unblock all
; Send PID to PSM as early as possible so recording/monitoring can begin
LogWrite("sending PID to PSM")
if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
; Terminate PSM Dispatcher utils wrapper
LogWrite("Terminating Dispatcher Utils Wrapper")
PSMGenericClient_Term()
Return $PSM_ERROR_SUCCESS
EndFunc
Func LoginProcess()
LogWrite("START -> LoginProcess()")
; Titles
Local $TITLE1 = "Check Point SmartConsole"
; Local $TITLE2 = $TargetAddress & " - SmartConsole"
; if ($TargetDomain <> "") Then
; $TITLE2 = $TargetDomain & " (" & $TargetAddress & ") - SmartConsole"
; AutoItSetOption("WinTitleMatchMode", 1) ; Match partial from the start
; EndIf
;Local $TITLE2 = "SmartConsole (" & $TargetAddress & ")"
;if ($TargetDomain <> "") Then
; $TITLE2 = "SmartConsole - " & $TargetDomain
; AutoItSetOption("WinTitleMatchMode", 1) ; Match partial from the start
;EndIf
; Check for fingerprint information
LogWrite("Check for fingerprint information")
sleep(10000)
WinActivate($TITLE1)
sleep($sleep)
Local $hwind1 = WinWaitActive($TITLE1,"",20)
If ($hwind1 <> 0) Then
ControlSend($TITLE1, "", "", "{ENTER}")
endIf
; delete login parameter file
LogWrite("deleting login parameters file")
FileDelete($LOGIN_PARMS_FILE)
LogWrite("Wait for application to load")
; SmartConsole - Login Windows
;~ WinActivate($TITLE2);
;~ sleep($sleep)
;~ WinWaitActive($TITLE2);
;~ $ConnectionClientPID = WinGetProcess($TITLE2)
LogWrite("END -> LoginProcess()")
EndFunc
;==================================
; Functions
;==================================
; #FUNCTION# ====================================================================================================================
; Name...........: Error
; Description ...: An exception handler - displays an error message and terminates the dispatcher
; Parameters ....: $ErrorMessage - Error message to display
; $Code - [Optional] Exit error code
; ===============================================================================================================================
Func Error($ErrorMessage, $Code = -1)
; If the dispatcher utils DLL was already initialized, write an error log message and terminate the wrapper
if (PSMGenericClient_IsInitialized()) Then
LogWrite($ErrorMessage, True)
PSMGenericClient_Term()
EndIf
Local $MessageFlags = BitOr(0, 16, 262144) ; 0=OK button, 16=Stop-sign icon, 262144=MsgBox has top-most attribute set
MsgBox($MessageFlags, $ERROR_MESSAGE_TITLE, $ErrorMessage)
; If the connection component was already invoked, terminate it
if ($ConnectionClientPID <> 0) Then
ProcessClose($ConnectionClientPID)
$ConnectionClientPID = 0
EndIf
Exit $Code
EndFunc
; #FUNCTION# ====================================================================================================================
; Name...........: LogWrite
; Description ...: Write a PSMWinSCPDispatcher log message to standard PSM log file
; Parameters ....: $sMessage - [IN] The message to write
; $LogLevel - [Optional] [IN] Defined if the message should be handled as an error message or as a trace messge
; Return values .: $PSM_ERROR_SUCCESS - Success, otherwise error - Use PSMGenericClient_PSMGetLastErrorString for details.
; ===============================================================================================================================
Func LogWrite($sMessage, $LogLevel = $LOG_LEVEL_TRACE)
Return PSMGenericClient_LogWrite($LOG_MESSAGE_PREFIX & $sMessage, $LogLevel)
EndFunc
; #FUNCTION# ====================================================================================================================
; Name...........: PSMGenericClient_GetSessionProperty
; Description ...: Fetches properties required for the session
; Parameters ....: None
; Return values .: None
; ===============================================================================================================================
Func FetchSessionProperties()
Local $ErrorPrefix="Connector failed to retrieve value of attribute:"
if (PSMGenericClient_GetSessionProperty("Address", $TargetAddress) <> $PSM_ERROR_SUCCESS) Then
Error($ErrorPrefix&"Address")
EndIf
if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then
Error($ErrorPrefix&"Username")
EndIf
if (PSMGenericClient_GetSessionProperty("Password", $TargetPassword) <> $PSM_ERROR_SUCCESS) Then
Error($ErrorPrefix&"Password")
EndIf
if (PSMGenericClient_GetSessionProperty("Address", $TargetAddress) <> $PSM_ERROR_SUCCESS) Then
Error($ErrorPrefix&"Address")
EndIf
if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then
Error($ErrorPrefix&"Username")
EndIf
if (PSMGenericClient_GetSessionProperty("PSMRemoteMachine", $TargetDomain) <> $PSM_ERROR_SUCCESS) Then
if (PSMGenericClient_GetSessionProperty("Domain", $TargetDomain) <> $PSM_ERROR_SUCCESS) Then
$TargetDomain=""
EndIf
EndIf
EndFunc