Suppress/Workaround: Remote Desktop Connection: A website wants to start a remote connection.

Issue: When you are connecting to an RDP session of Windows systems starting Server 2008 and Vista OSes, you’ll see below prompt that user needs to respond. This is an expected behavior by RDP starting these versions. However, this becomes an issue if you are automating RDP access to the servers via ActiveX or other programming models.

image

 

Suppressing above prompt for Automation tasks:

  • Download WASP module files from: Windows Automation Snapin for PowerShell
  • Import the WASP module into the Powershell:
  • PS C:> Import-Module "C:DownloadsWASPWASPWASP.dll"
    PS C:>

  • Verify that WASP module is loaded fine by running below command:
  • PS C:> Get-Module

    ModuleType Name                                ExportedCommands
    ———- —-                                —————-
    Manifest   Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content…}
    Manifest   Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object…}
    Binary     WASP                                {Set-WindowActive, Send-Click, Set-WindowPosition, Get-WindowPosition…

    PS C:>

  • Now you’ll be able to run the WASP cmdlets

Use WASP Module in PowerShell:

  1. Identify the MSRDP ActiveX loaded window process,
  2. Get all of it’s child Windows (The above prompt will be a child window of actual RDP Window)
  3. Find the prompt window by matching it’s tile
  4. Send a click command to the Window so that it’s respond to prompt with OK option
  5. Then RDP connection the RDP continues without waiting for user to respond to the prompt.

 

Select-Window -ProcessName ms* | Select-ChildWindow | select-control -title co* | send-click

 

Command Step-By-Step:

PS C:> Select-Window -ProcessName ms*

ProcessName : mstsc
ProcessId   : 7564
IsActive    : False
Handle      : 1316128
Title       : 175.23.1.193 – Remote Desktop Connection
Class       : TscShellContainerClass

PS C:> Select-Window -ProcessName ms* | Select-ChildWindow

                                 Handle Title                                   Class
                                 —— —–                                   —–
                                 202558 Remote Desktop Connection               #32770

PS C:> Select-Window -ProcessName ms* | Select-ChildWindow | select-control -title co* | ft -auto

Handle Title    Class
—— —–    —–
267848 Co&nnect Button

PS C:>

Select-Window -ProcessName ms* | Select-ChildWindow | select-control -title co* | send-click
PS C:>

Leave a Reply

Your email address will not be published. Required fields are marked *