Skip to content

Start RDP sessions silently #131

Done

Description

@Sqweeksyg

Hi OI,

When we start the RDP sessions from the SPP web page, Scalus opens the Windows cmd line, shows some commands and it closes.
Would it be possible to run it silently to avoid disturbing users during the connection establishment?

Thank you for your nice job!

Activity

  1. self-assigned this
    on Jun 22, 2023
  2. nawazsarwar124 commented on Sep 21, 2023

    @nawazsarwar124

    Did you find a way to start the session silently?

  3. Sqweeksyg commented on Sep 25, 2023

    @Sqweeksyg
    Author

    Not yet...
    @JaredCuster do you have any news?

    Thank you!

  4. nircamon82 commented on Jun 26, 2024

    @nircamon82

    Hi, any news on that? did you find a way to start it silently?

  5. uobnsturner commented on Oct 22, 2024

    @uobnsturner

    Would be great if this silent opening could be done.

  6. altiris4ever commented on Oct 25, 2024

    @altiris4ever

    EDIT, adding wall of text: It seems to be hardcoded to run scalus maximized in the terminal window, either by design or by a windows terminal bug. So i guess that has to be changed in the way Scalus open windows terminal in the sourcecode. As a workaround I even tried creating my own script that looks for the terminal process and a tab/windows called "C:\Program Files\SCALUS\scalus.exe" because I have done something similar before. I could get it closed automatically by running the script as admin and editing this values:
    $WindowPartialTitle = "C:\Program Files\SCALUS\scalus.exe" # Part of the title of the dialog to close
    $TargetProcessName = "windowsterminal" # Name of the target process
    But as mention over there seem to be no way to minimizing the window or closing the tab. I'm not sure if it's a bug or a feature... And to auto close the windows you have to run the script as admin because windows terminal is started in that context, that will require running the script as a scheduled task running as admin, or creating a service doing the same, and it will need to trigger automatically when scalus.exe starts (not easy), or at system startup looking for the process constantly (consuming cpu cycles). And then you need to remove the part looking for windows terminal before the script would start.

    But the the easy workaround is to limit the amount of data that's being shown to the user. This is done by editing the config file called "appsettings.json" in the folder "C:\Program Files\SCALUS". By changing the value "Console": true to false only the text community edition will now show in the terminal:
    For all parameters I copy pasted from the wiki here:
    Configuration
    appsettings.json can be used to customize the runtime SCALUS behavior. Set MinLevel to Debug to get more detailed log file output. Set Console to true to log to the console window. Configuration files are stored in the user's profile folder as determined by the OS. Use the scalus info command to see full paths to log and configuration files.

    {
    "Logging": {
    "FileName": "scalus.log",
    "MinLevel": "Information",
    "Console": true
    },
    "Configuration": {
    "FileName": "scalus.json"
    }
    }
    Usage
    SCALUS command-line usage:

    Session Client Application Launch Uri System (SCALUS)
    Copyright (c) 2022 One Identity LLC

    info Show information about the current SCALUS configuration
    launch Launch an app configured for the specified URL
    register Register SCALUS to handle URLs
    ui (Default Verb) Run the configuration UI
    unregister Unregister SCALUS for URL handling
    verify Run a syntax check on a SCALUS configuration file
    help Display more information on a specific command.
    version Display version information.

  7. altiris4ever commented on Jul 4, 2025

    @altiris4ever

    I found a method to also run the windows minimized by creating the following .ps1 script, but of course this script has to be started before using scalus as a startupscript or as a scheduled task since it monitoring prosesses for windows title and minimizing it:

    <#
    .SYNOPSIS
      Polls for a specific Windows Terminal tab and minimizes its window when found.
    
    .PARAMETER Match
      Ending substring of the tab title to match (default: full path to scalus.exe).
    
    .PARAMETER AggressiveInterval
      Seconds between checks during the aggressive phase (default: 2).
    
    .PARAMETER AggressiveTimeout
      Maximum seconds to spend in the aggressive phase (default: 120).
    
    .PARAMETER IdleInterval
      Seconds between checks during the idle phase (default: 30).
    
    .PARAMETER IdleTimeout
      Maximum seconds to spend in the idle phase; 0 = indefinite (default: 0).
    
    .PARAMETER ExitAfterMinimize
      If specified, exit immediately once minimized; otherwise continue idle polling.
    
    .EXAMPLE
      # Aggressive 1s interval for 60s, then idle 15s indefinitely, exit on minimize
      .\MinimerRPD.ps1 -Match "scalus.exe" -AggressiveInterval 1 -AggressiveTimeout 60 `
        -IdleInterval 15 -IdleTimeout 0 -ExitAfterMinimize
    #>
    
    param(
        [string]$Match               = 'C:\Program Files\SCALUS\scalus.exe',
        [int]   $AggressiveInterval  = 2,
        [int]   $AggressiveTimeout   = 120,
        [int]   $IdleInterval        = 30,
        [int]   $IdleTimeout         = 0,
        [switch]$ExitAfterMinimize
    )
    
    # Resolve log file path in the user’s TEMP folder
    $LogFile = Join-Path $env:TEMP 'MinimerRPD.log'
    
    # Start logging
    "===== Script start: $(Get-Date -Format s) =====" | Out-File $LogFile -Encoding utf8
    "Parameters: Match='${Match}', AggressiveInterval=${AggressiveInterval}, AggressiveTimeout=${AggressiveTimeout}, IdleInterval=${IdleInterval}, IdleTimeout=${IdleTimeout}, ExitAfterMinimize=${ExitAfterMinimize}" | Add-Content $LogFile
    
    # Load Win32 API for minimizing windows (SW_MINIMIZE = 6)
    Add-Type -MemberDefinition @'
        [DllImport("user32.dll")]
        public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
    '@ -Name Win32 -Namespace Native
    
    # --------- Aggressive polling phase ---------
    $swAggressive = [Diagnostics.Stopwatch]::StartNew()
    while ($swAggressive.Elapsed.TotalSeconds -lt $AggressiveTimeout) {
        $ts = Get-Date -Format s
        $wins = Get-Process -Name WindowsTerminal -ErrorAction SilentlyContinue |
                Where-Object { $_.MainWindowTitle.EndsWith($Match, [StringComparison]::OrdinalIgnoreCase) }
    
        if ($wins) {
            "${ts}: [Aggressive] Found $($wins.Count) matching window(s). Minimizing..." | Add-Content $LogFile
            foreach ($w in $wins) { [Native.Win32]::ShowWindowAsync($w.MainWindowHandle,6) | Out-Null }
            "${ts}: [Aggressive] Window(s) minimized." | Add-Content $LogFile
    
            if ($ExitAfterMinimize) {
                "${ts}: ExitAfterMinimize specified; exiting now." | Add-Content $LogFile
                exit
            }
            break
        }
    
        "${ts}: [Aggressive] No match yet. Sleeping ${AggressiveInterval}s..." | Add-Content $LogFile
        Start-Sleep -Seconds $AggressiveInterval
    }
    "${([DateTime]::Now.ToString('s'))}: Aggressive phase complete." | Add-Content $LogFile
    
    # --------- Idle polling phase ---------
    $swIdle = [Diagnostics.Stopwatch]::StartNew()
    while ($IdleTimeout -eq 0 -or $swIdle.Elapsed.TotalSeconds -lt $IdleTimeout) {
        $ts = Get-Date -Format s
        $wins = Get-Process -Name WindowsTerminal -ErrorAction SilentlyContinue |
                Where-Object { $_.MainWindowTitle.EndsWith($Match,[StringComparison]::OrdinalIgnoreCase) }
    
        if ($wins) {
            "${ts}: [Idle] Found $($wins.Count) matching window(s). Minimizing..." | Add-Content $LogFile
            foreach ($w in $wins) {
                [Native.Win32]::ShowWindowAsync($w.MainWindowHandle,6) | Out-Null
            }
            if ($ExitAfterMinimize) {
                "${ts}: ExitAfterMinimize specified; exiting now." | Add-Content $LogFile
                break
            }
            # ellers: fortsett å poll’e
        }
        else {
            "${ts}: [Idle] No match. Sleeping ${IdleInterval}s..." | Add-Content $LogFile
        }
    
        Start-Sleep -Seconds $IdleInterval
    }
    
    "===== Script end: $(Get-Date -Format s) =====`n" | Add-Content $LogFile
    
    

    Usage examples

    1. Default behavior (no parameters):

      .\MinimerRPD.ps1
    2. Exit immediately after minimize:

      .\MinimerRPD.ps1 -ExitAfterMinimize
    3. Custom aggressive phase:

      .\MinimerRPD.ps1 -AggressiveInterval 1 -AggressiveTimeout 60
    4. Limited idle phase:

      .\MinimerRPD.ps1 -IdleInterval 10 -IdleTimeout 300
    5. Fully customized:

      .\MinimerRPD.ps1 `
        -Match "scalus.exe" `
        -AggressiveInterval 1 -AggressiveTimeout 90 `
        -IdleInterval 15 -IdleTimeout 0 `
        -ExitAfterMinimize
  8. added
    enhancement
    on Mar 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions