Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DexterDreeeam committed Feb 23, 2023
1 parent 97223e2 commit 7c811eb
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions agent/agent_installer/Windows/Android/installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ if ((New-Object Security.Principal.WindowsPrincipal $([Security.Principal.Window
{
$E2E = Read-Host "Is E2E(End to End) Test needed in your test? (Y/N)"
}
if (($E2E -eq 'Y') -or ($E2E -eq 'y'))
{
$taskTrigger = New-ScheduledTaskTrigger -AtLogon
$taskAction = New-ScheduledTaskAction -Execute "$CurrentScriptPath\restartAgent.bat"
Register-ScheduledTask -TaskName "HydraLabAgentRestart" -Trigger $taskTrigger -Action $taskAction
Copy-Item "$CurrentScriptPath\restartAgent_WindowsTaskScheduler.bat" -Destination "$CurrentScriptPath\restartAgent.bat" -Force

Write-Host "E2E test need to logon Windows automatically, please input Windows User-Name and Password to set Auto-Logon"
Write-Host

$logonRegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
$logonUserName = Read-Host "Windows Logon User-Name: "
$logonPassword = Read-Host "Windows Logon Password: "
New-ItemProperty -Path $logonRegistryPath -Name "DefaultUserName" -Value $logonUserName -PropertyType String -Force | Out-Null
New-ItemProperty -Path $logonRegistryPath -Name "DefaultPassword" -Value $logonPassword -PropertyType String -Force | Out-Null
New-ItemProperty -Path $logonRegistryPath -Name "AutoAdminLogon" -Value "1" -PropertyType String -Force | Out-Null
}
else
{
Copy-Item "$CurrentScriptPath\restartAgent_WindowsService.bat" -Destination "$CurrentScriptPath\restartAgent.bat" -Force
}

$destination = Join-Path (Convert-Path "~") "Downloads"

Expand Down Expand Up @@ -479,21 +500,6 @@ if ((New-Object Security.Principal.WindowsPrincipal $([Security.Principal.Window
}
Write-Host

Write-Host "9. Setting restart approach"
Write-Host

if (($E2E -eq 'Y') -and ($E2E -eq 'y'))
{
$taskTrigger = New-ScheduledTaskTrigger -AtLogon
$taskAction = New-ScheduledTaskAction -Execute "$CurrentScriptPath\restartAgent.bat"
Register-ScheduledTask -TaskName "HydraLabAgentRestart" -Trigger $taskTrigger -Action $taskAction
Copy-Item "$CurrentScriptPath\restartAgent_WindowsTaskScheduler.bat" -Destination "$CurrentScriptPath\restartAgent.bat" -Force
}
else
{
Copy-Item "$CurrentScriptPath\restartAgent_WindowsService.bat" -Destination "$CurrentScriptPath\restartAgent.bat" -Force
}

Write-Host "The agent deployment is complete, please reboot before start the agent"
Write-Host

Expand Down

0 comments on commit 7c811eb

Please sign in to comment.