rustdeskinstall/WindowsAgentAIOInstall.ps1

82 lines
3.1 KiB
PowerShell
Raw Normal View History

2022-08-03 00:59:40 +02:00
$ErrorActionPreference= 'silentlycontinue'
2022-08-29 16:01:55 +02:00
#Run as administrator and stays in the current directory
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-12 10:09:08 +02:00
# Replace wanipreg and keyreg with the relevant info for your install. IE wanipreg becomes your rustdesk server IP or DNS and keyreg becomes your public key.
2022-08-03 00:59:40 +02:00
function OutputIDandPW([String]$rustdesk_id, [String]$rustdesk_pw) {
Write-Output("######################################################")
Write-Output("# #")
Write-Output("# CONNECTION PARAMETERS: #")
Write-Output("# #")
Write-Output("######################################################")
Write-Output("")
Write-Output(" RustDesk-ID: $rustdesk_id")
Write-Output(" RustDesk-Password: $rustdesk_pw")
Write-Output("")
2022-08-03 00:59:40 +02:00
}
If (!(Test-Path $env:Temp)) {
New-Item -ItemType Directory -Force -Path $env:Temp > null
}
2022-08-17 17:08:33 +02:00
If (!(Test-Path "$env:ProgramFiles\Rustdesk\RustDesk.exe")) {
cd $env:Temp
2023-07-05 18:42:55 +02:00
Invoke-WebRequest https://github.com/rustdesk/rustdesk/releases/download/1.2.0/rustdesk-1.2.0-x86_64.exe -Outfile rustdesk.exe
2023-07-05 18:42:55 +02:00
Start-Process "rustdesk.exe" -argumentlist "--silent-install" -wait
2022-08-17 17:01:08 +02:00
# Cleanup Tempfiles
cd $env:Temp
2023-07-11 23:07:27 +02:00
Remove-Item $env:Temp\rustdesk.exe -Recurse > null
2022-08-09 01:02:25 +02:00
}
2022-08-05 12:51:15 +02:00
2022-08-09 01:05:28 +02:00
# Write config
$RustDesk2_toml = @"
rendezvous_server = 'wanipreg'
nat_type = 1
serial = 0
[options]
custom-rendezvous-server = 'wanipreg'
2022-08-17 19:54:35 +02:00
key = 'keyreg'
relay-server = 'wanipreg'
api-server = 'https://wanipreg'
2022-08-17 18:13:00 +02:00
enable-audio = 'N'
"@
If (!(Test-Path $env:AppData\RustDesk\config\RustDesk2.toml)) {
New-Item $env:AppData\RustDesk\config\RustDesk2.toml > null
}
Set-Content $env:AppData\RustDesk\config\RustDesk2.toml $RustDesk2_toml > null
If (!(Test-Path $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml)) {
New-Item $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml > null
}
Set-Content $env:WinDir\ServiceProfiles\LocalService\AppData\Roaming\RustDesk\config\RustDesk2.toml $RustDesk2_toml > null
2022-08-03 00:59:40 +02:00
2022-08-28 23:20:20 +02:00
$random_pass = (-join ((65..90) + (97..122) | Get-Random -Count 8 | % {[char]$_}))
Start-Process "$env:ProgramFiles\RustDesk\RustDesk.exe" -argumentlist "--password $random_pass" -wait
2022-08-09 16:16:19 +02:00
2023-07-05 18:42:55 +02:00
net stop rustdesk > null
$ProcessActive = Get-Process rustdesk -ErrorAction SilentlyContinue
if($ProcessActive -ne $null)
{
stop-process -ProcessName rustdesk -Force
2022-08-09 16:16:19 +02:00
}
2022-08-03 00:59:40 +02:00
2023-07-05 18:42:55 +02:00
$rustdesk_pw = (-join ((65..90) + (97..122) | Get-Random -Count 12 | % {[char]$_}))
Start-Process "$env:ProgramFiles\RustDesk\RustDesk.exe" "--password $rustdesk_pw" -wait
Write-Output "$rustdesk_pw"
net start rustdesk > null
Stop-Process -Name RustDesk -Force > null
Start-Service -Name RustDesk > null