diff --git a/enos/modules/aws_windows_client/main.tf b/enos/modules/aws_windows_client/main.tf index f8aff1933..daa6f0a28 100644 --- a/enos/modules/aws_windows_client/main.tf +++ b/enos/modules/aws_windows_client/main.tf @@ -231,7 +231,7 @@ resource "aws_instance" "client" { New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 # Create a non-admin user to be used for RDP connection. This - # is needed since the scheduled task that runs pyautogui + # is needed since the scheduled task that runs desktop automation # doesn't work in an Administrator context. ## Create a local user $Username = "${local.test_username}" @@ -239,6 +239,16 @@ resource "aws_instance" "client" { New-LocalUser $Username -Password $Password -FullName "Auto Login User" -Description "User for Auto Login" Add-LocalGroupMember -Group "Administrators" -Member $Username + # Disable windows snapping assist. This is done to reduce + # complexity in RDP automated tests since the snapping assist + # window introduces an additional UI element that needs to be handled. + Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced" -Name "SnapAssist" -Value 0 -Force + + $script = 'Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SnapAssist" -Value 0 -Force; Stop-Process -Name explorer -Force; Start-Process explorer.exe' + $action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NonInteractive -WindowStyle Hidden -Command $script" + $trigger = New-ScheduledTaskTrigger -AtLogOn -User "autologinuser" + Register-ScheduledTask -TaskName "RemoveSnapAssist" -Action $action -Trigger $trigger -User "autologinuser" -RunLevel Highest -Force + # Set registry keys for auto-login $regPath = "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon" Set-ItemProperty -Path $regPath -Name "AutoAdminLogon" -Value "1" -Type String