Custom Remote App Launcher Record Types

The following article will describe the process to create your own high trust remote application launcher in PAM.

PAM uses scripts written and developed for AutoIt, so if you are not familiar with that application or its scripting language, it’s a good time to learn more about it here.

Now that you are familiar with AutoIt, let’s continue with the article.

AutoIt Record

  1. Login to PAM using a System Administrator account.
  2. Navigate to Administration > Scripts.
  3. Click the Create button to create your new Remote App launcher script.
  4. Enter a Script Name, Description and for Job Execution Strategy select the option RemoteApp.
  5. Write or paste in your AutoIt script in the Custom Code (AutoIt) field. For an example script, click here.
  6. Click the Save button when you are finished.
  7. With the script saved, navigate to Administration > Record Types and click the New Record Type button.
  8. Enter a Name, Description, Session Manager select RemoteApp and finally for Remote App Script select your new script name from the previous step.
  9. Create the rest of the record type as needed. For example, if you create a custom field named URL, then you can reference this value in your remote app script so that AutoIt will automatically enter it during connection.
  10. Click Save when you are finished.

Now you can navigate to Records > All Records and create a new record using this record type. Test the new record by clicking the Connect button to ensure it is working as expected before deploying to production.

Remember, this procedure requires the prior deployment and configuration of Windows Remote Desktop Services with RemoteApp functionality, so if you have not configured your Remote App Host connection yet, it is recommended to review this Getting Started Guide.

PAM AutoIt Script Examples

MS SQL Server Management Studio Remote App Launcher Script

Copy
#include <XTAM.au3>

Local Const $SSMS_EXECUTABLE = "C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe"
Local Const $SERVER_CLASS = "[CLASS:Edit; INSTANCE:1]"
Local Const $LOGIN_CLASS = "[CLASS:Edit; INSTANCE:2]"
Local Const $PASSWD_CLASS = "[NAME:password]"
Local Const $CONNECT_CLASS = "[NAME:connect]"
Local Const $AUTH_CLASS = "[NAME:comboBoxAuthentication]"
Local Const $WIN_MAIN = "[REGEXPTITLE:(?i)(.*Microsoft SQL Server Management Studio)]"

Local $hostname
Local $username
Local $password

$params = XtamGetProperties()

$len = Ubound($params)

For $i = 0 to $len - 1 Step 2
    If $params[$i] = "Host_raw" Then
        $hostname = $params[$i+1]
    ElseIf $params[$i] = "User_raw" Then
        $username = $params[$i+1]
    ElseIf $params[$i] = "Password_raw" Then
        $password = $params[$i+1]
    EndIf
Next

ConsoleWrite("Executing " & $SSMS_EXECUTABLE & @CRLF)
$process = Run($SSMS_EXECUTABLE)

If @error Then
    ConsoleWrite("Failed to run program: " & @error & @CRLF)
    Exit
EndIf

ConsoleWrite("Waiting for window" & @CRLF)
WinWaitActive("Connect to Server", "", 10000)
$hwnd = WinGetHandle("Connect to Server")

ConsoleWrite("Input params" & @CRLF)
ControlSend($hwnd, "", $AUTH_CLASS, "S") ; select 'SQL Server Authentication' type
ControlSetText($hwnd, "", $SERVER_CLASS, $hostname)
ControlSetText($hwnd, "", $LOGIN_CLASS, $username)
ControlSetText($hwnd, "", $PASSWD_CLASS, $password)
ControlSend($hwnd, "", $CONNECT_CLASS, "{ENTER}")

XtamSendDone()

ConsoleWrite("Waiting application close" & @CRLF)
WinWaitClose($WIN_MAIN)
ConsoleWrite("Exiting..." & @CRLF)

Shutdown(0) ; Logoff