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.
Suppressing above prompt for Automation tasks:
- Download WASP module files from: Windows Automation Snapin for PowerShell
- Import the WASP module into the Powershell:
- Verify that WASP module is loaded fine by running below command:
- Now you’ll be able to run the WASP cmdlets
PS C:> Import-Module "C:DownloadsWASPWASPWASP.dll"
PS C:>
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:>
Use WASP Module in PowerShell:
- Identify the MSRDP ActiveX loaded window process,
- Get all of it’s child Windows (The above prompt will be a child window of actual RDP Window)
- Find the prompt window by matching it’s tile
- Send a click command to the Window so that it’s respond to prompt with OK option
- 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 : TscShellContainerClassPS C:> Select-Window -ProcessName ms* | Select-ChildWindow
Handle Title Class
—— —– —–
202558 Remote Desktop Connection #32770PS C:> Select-Window -ProcessName ms* | Select-ChildWindow | select-control -title co* | ft -auto
Handle Title Class
—— —– —–
267848 Co&nnect ButtonPS C:>
Select-Window -ProcessName ms* | Select-ChildWindow | select-control -title co* | send-click
PS C:>