rustdeskinstall/WindowsAgentAIOInstall.ps1

69 lines
2.2 KiB
PowerShell
Raw Normal View History

2022-08-03 00:59:40 +02:00
$ErrorActionPreference= 'silentlycontinue'
2024-03-15 11:48:11 +01:00
# Assign the value random password to the password variable
$rustdesk_pw=(-join ((65..90) + (97..122) | Get-Random -Count 12 | % {[char]$_}))
# Get your config string from your Web portal and Fill Below
$rustdesk_cfg="secure-string"
################################### Please Do Not Edit Below This Line #########################################
# Run as administrator and stays in the current directory
2022-08-29 16:01:55 +02:00
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
if ([int](Get-CimInstance -Class Win32_OperatingSystem | Select-Object -ExpandProperty BuildNumber) -ge 6000) {
Start-Process PowerShell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"cd '$pwd'; & '$PSCommandPath';`"";
Exit;
}
}
2022-08-03 00:59:40 +02:00
2024-03-15 11:48:11 +01:00
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
2024-03-15 11:48:11 +01:00
if($rdver -eq "1.2.2")
{
write-output "RustDesk $rdver is the newest version"
2024-03-15 11:48:11 +01:00
exit
}
2023-08-24 10:25:07 +02:00
2024-03-15 11:48:11 +01:00
If (!(Test-Path C:\Temp)) {
New-Item -ItemType Directory -Force -Path C:\Temp > null
2023-08-24 10:25:07 +02:00
}
2024-03-15 11:48:11 +01:00
cd C:\Temp
powershell Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/1.2.3-1/rustdesk-1.2.3-1-x86_64.exe" -Outfile "rustdesk.exe"
2023-08-24 10:25:07 +02:00
Start-Process .\rustdesk.exe --silent-install -wait
2023-08-24 10:25:07 +02:00
$ServiceName = 'Rustdesk'
$arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
2022-08-05 12:51:15 +02:00
2023-08-24 10:25:07 +02:00
if ($arrService -eq $null)
{
2024-03-15 11:48:11 +01:00
Write-Output "Installing service"
cd $env:ProgramFiles\RustDesk
Start-Process .\rustdesk.exe --install-service -wait -Verbose
2023-08-24 10:25:07 +02:00
Start-Sleep -seconds 20
}
2023-08-24 10:25:07 +02:00
while ($arrService.Status -ne 'Running')
{
Start-Service $ServiceName
Start-Sleep -seconds 5
$arrService.Refresh()
}
2023-08-24 10:25:07 +02:00
2024-03-15 11:48:11 +01:00
cd $env:ProgramFiles\RustDesk\
.\RustDesk.exe --get-id | Write-Output -OutVariable rustdesk_id
2023-07-05 18:42:55 +02:00
2024-03-15 11:48:11 +01:00
.\RustDesk.exe --config $rustdesk_cfg
2023-07-05 18:42:55 +02:00
2024-04-10 11:06:43 +02:00
.\RustDesk.exe --password $rustdesk_pw
2023-08-24 10:25:07 +02:00
2024-03-15 11:48:11 +01:00
Write-Output "..............................................."
# Show the value of the ID Variable
Write-Output "RustDesk ID: $rustdesk_id"
2023-08-24 10:25:07 +02:00
2024-03-15 11:48:11 +01:00
# Show the value of the Password Variable
Write-Output "Password: $rustdesk_pw"
Write-Output "..............................................."