- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
05-08-2025 04:06 AM
I've created an AutoIt script to automate login to the Barracuda Firewall Admin GUI using credentials fetched from CyberArk. After numerous attempts, the script successfully connected to the Barracuda firewall and filled in the credentials on the first run.
However, when I try to connect again, the script fails to fill in the credentials, and I receive the error: Failed to open process (process id: xxx)
PS
Barracuda Admin is not a traditional installable app — it's a self-contained GUI executable. It just opens directly and allows credential entry.
When testing manually, Run() didn’t work to launch it. So I used ShellExecute() , and it worked fine.
Oddly, when running the script via CyberArk, Run() works, and the Barracuda GUI opens correctly.
However, after Barracuda opens, I get the error.
Here is the script I'm using:
;=======================================
; 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()
LogWrite("mapping local drives")
if (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
LogWrite("starting client application")
ToolTip ("Starting " & $DISPATCHER_NAME & "...")
$ConnectionClientPID = Run($CLIENT_EXECUTABLE)
if ($ConnectionClientPID == 0) Then
Error(StringFormat("Failed to execute process [%s]", $CLIENT_EXECUTABLE, @error))
EndIf
; Launch the application
Run($CLIENT_EXECUTABLE)
; Wait for the window to appear
WinWait("Barracuda Firewall Admin 9.0 - New Session", "", 30)
Sleep(3000)
If WinExists("Barracuda Firewall Admin 9.0 - New Session") Then
Send($TargetAddress)
Send("{TAB}")
Send($TargetUsername)
Send("{TAB}")
Send($TargetPassword)
Send("{ENTER}")
Else
MsgBox(16, "Error", "Login window NOT found.")
EndIf
; ------------------
; Handle login here! ; CHANGE_ME
; ------------------
; Send PID to PSM so recording/monitoring can begin
; Notice that until we send the PID, PSM blocks all user input.
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
;==================================
; 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() ; CHANGE_ME
if (PSMGenericClient_GetSessionProperty("Username", $TargetUsername) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
if (PSMGenericClient_GetSessionProperty("Password", $TargetPassword) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
if (PSMGenericClient_GetSessionProperty("Address", $TargetAddress) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
EndFunc
Has anyone faced a similar issue or can help identify what might be going wrong?
Any insights or suggestions would be greatly appreciated!
05-08-2025 04:37 AM
I would recommend removing the duplicate of running the client executable. most probably the application doesn't support multiple instances and therefore you receive the error. try removing the part below and rerun again:
; Launch the application
Run($CLIENT_EXECUTABLE)
05-22-2025 12:02 AM
Hello @Bellatrix Lestrange
Have you received an answer to your question? If so, we kindly encourage you to share it with us.
Your insights could be valuable to other community members in the future.
Thank you, Isar.
06-08-2025 10:22 PM
Changed the script and it worked.
Global Const $DISPATCHER_NAME = "PSMBarracuda"
Global Const $CLIENT_EXECUTABLE = "C:\Tools\FirewallAdmin_9.0.0-277.exe"
Global Const $ERROR_MESSAGE_TITLE = "PSM " & $DISPATCHER_NAME & " Dispatcher Error"
Global Const $LOG_MESSAGE_PREFIX = $DISPATCHER_NAME & " Dispatcher - "
Global $TargetAddress, $TargetUsername, $TargetPassword
Global $ConnectionClientPID = 0
Exit Main()
Func Main()
If (PSMGenericClient_Init() <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
FetchSessionProperties()
If (PSMGenericClient_MapTSDrives() <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
ShellExecute($CLIENT_EXECUTABLE) ; Launch app normally
; Wait for login window
WinWait("Barracuda Firewall Admin 9.0 - New Session", "", 20)
Local $hWnd = WinGetHandle("Barracuda Firewall Admin 9.0 - New Session")
If $hWnd = 0 Then Error("Login window NOT found.")
Sleep(1000)
; Get actual process PID of the GUI
$ConnectionClientPID = WinGetProcess($hWnd)
If $ConnectionClientPID = 0 Then
Error("Could not get PID of the GUI process.")
EndIf
; Fill credentials
WinActivate($hWnd)
Send($TargetAddress)
Send("{TAB}")
Send($TargetUsername)
Send("{TAB}")
Send($TargetPassword)
Send("{ENTER}")
06-10-2025 06:13 AM
@Bellatrix Lestrange , please be aware that in your changed script, you don't send the PID to the PSM and it will cause session not being monitored and recorded.
I would include the following to capture the session before filling credentials:
LogWrite("sending PID to PSM")
if (PSMGenericClient_SendPID($ConnectionClientPID) <> $PSM_ERROR_SUCCESS) Then
Error(PSMGenericClient_PSMGetLastErrorString())
EndIf
06-10-2025 09:35 PM
Thank You! But whenever iam trying to give PID it throws error- "PSMSR163E failed to open process( process id: xxxxxx)"
06-10-2025 09:57 PM
Some generic questions related to the environment:
06-10-2025 10:24 PM
06-10-2025 10:36 PM
But without sending PID, connector works fine. right?
06-20-2025 12:15 AM
strange. Better to turn on trace mode fo Connnection Client Settings and the PSM itself and debug this connection. there should definitely be something that points out to the reason
06-20-2025 05:08 AM
Hi @Bellatrix Lestrange
Have you whitelisted Barracuda executable from AppLocker rules ?
And sometimes the window is present, but its process is still initializing or loading its dependencies.
Try adding a longer delay after WinWait()
Hope it helps !
06-22-2025 09:37 PM
As of now the session is recording.
06-22-2025 11:42 PM
what made it working?
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

