Skip to content

Commit 5885a40

Browse files
authored
chore(e2e): Disable snap assist (#6214)
1 parent 25847c3 commit 5885a40

File tree

1 file changed

+11
-1
lines changed
  • enos/modules/aws_windows_client

1 file changed

+11
-1
lines changed

enos/modules/aws_windows_client/main.tf

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,24 @@ resource "aws_instance" "client" {
231231
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
232232
233233
# Create a non-admin user to be used for RDP connection. This
234-
# is needed since the scheduled task that runs pyautogui
234+
# is needed since the scheduled task that runs desktop automation
235235
# doesn't work in an Administrator context.
236236
## Create a local user
237237
$Username = "${local.test_username}"
238238
$Password = ConvertTo-SecureString "${local.test_password}" -AsPlainText -Force
239239
New-LocalUser $Username -Password $Password -FullName "Auto Login User" -Description "User for Auto Login"
240240
Add-LocalGroupMember -Group "Administrators" -Member $Username
241241
242+
# Disable windows snapping assist. This is done to reduce
243+
# complexity in RDP automated tests since the snapping assist
244+
# window introduces an additional UI element that needs to be handled.
245+
Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced" -Name "SnapAssist" -Value 0 -Force
246+
247+
$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'
248+
$action = New-ScheduledTaskAction -Execute "powershell.exe" -Argument "-NonInteractive -WindowStyle Hidden -Command $script"
249+
$trigger = New-ScheduledTaskTrigger -AtLogOn -User "autologinuser"
250+
Register-ScheduledTask -TaskName "RemoveSnapAssist" -Action $action -Trigger $trigger -User "autologinuser" -RunLevel Highest -Force
251+
242252
# Set registry keys for auto-login
243253
$regPath = "HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"
244254
Set-ItemProperty -Path $regPath -Name "AutoAdminLogon" -Value "1" -Type String

0 commit comments

Comments
 (0)