-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrustdesk-install.ps1
47 lines (37 loc) · 1.63 KB
/
rustdesk-install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$ErrorActionPreference = 'SilentlyContinue'
#Region Settings
# Variables
$Key = ""
$IpAddress = "10.22.10.222"
# The temporary folder where we will store and run the installer
$TempFolder = "C:\Temp\"
#EndRegion Settings
# Check if we are running in admin context
function Test-IsElevated {
$id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$p = New-Object System.Security.Principal.WindowsPrincipal($id)
$p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (-not (Test-IsElevated)) {
Write-Error -Message "Access Denied. Please run with Administrator privileges."
exit 1
}
# Check if RustDesk is already installed and exit if it is installed
if ((Test-Path -Path "C:\Program Files\RustDesk\RustDesk.exe")) {
"RustDesk already installed."
exit 0
}
# Create our temp folder if it doesn't exist
if (!(Test-Path -Path $TempFolder)) {
New-Item -ItemType Directory -Force -Path $TempFolder
}
# Change the current location to the temp folder
Set-Location $TempFolder
# Download version 1.2.3-1 of RustDesk, output specific file name.
Invoke-WebRequest -Uri "https://github.com/rustdesk/rustdesk/releases/download/1.2.3-1/rustdesk-1.2.3-1-x86_64.exe" -Outfile rustdesk-1.2.3-1-x86_64.exe
# Rename the installer to configure the installer; Add host (Relay/API) and Key.
Rename-Item -Path .\rustdesk-1.2.3-1-x86_64.exe -NewName "rustdesk-host=$IpAddress,key=$Key,.exe"
# Run the installer silently
$Process = Start-Process -FilePath ".\rustdesk-host=$IpAddress,key=$Key,.exe" -ArgumentList "--silent-install" -PassThru
# Exit with what ever exit code the installer returns
exit $Process.ExitCode