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
2022-08-17 16:42:02 +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 " )
2022-08-17 16:44:43 +02:00
Write-Output ( " " )
2022-08-03 00:59:40 +02:00
}
2022-08-17 16:42:02 +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 " ) ) {
2022-08-17 16:42:02 +02:00
2023-08-24 10:25:07 +02:00
$ErrorActionPreference = 'silentlycontinue'
If ( ! ( Test-Path c: \ Temp ) ) {
New-Item -ItemType Directory -Force -Path c: \ Temp > null
}
2022-08-17 16:42:02 +02:00
2023-08-24 10:25:07 +02:00
cd c: \ Temp
2022-08-17 16:42:02 +02:00
2023-08-24 10:25:07 +02:00
powershell Invoke-WebRequest " https://github.com/rustdesk/rustdesk/releases/download/1.2.2/rustdesk-1.2.2-x86_64.exe " -Outfile " rustdesk.exe "
Start-Process . \ rustdesk . exe - -silent -install -wait
2022-08-17 16:42:02 +02:00
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 )
{
Start-Sleep -seconds 20
2022-08-17 17:56:31 +02:00
}
2023-08-24 10:25:07 +02:00
while ( $arrService . Status -ne 'Running' )
{
Start-Service $ServiceName
Start-Sleep -seconds 5
$arrService . Refresh ( )
2022-08-17 17:56:31 +02:00
}
2023-08-24 10:25:07 +02:00
net stop rustdesk
$username = ( ( Get-WMIObject -ClassName Win32_ComputerSystem ) . Username ) . Split ( '\' ) [ 1 ]
Remove-Item C: \ Users \ $username \ AppData \ Roaming \ RustDesk \ config \ RustDesk2 . toml
New-Item C: \ Users \ $username \ AppData \ Roaming \ RustDesk \ config \ RustDesk2 . toml
Set-Content C: \ Users \ $username \ AppData \ Roaming \ RustDesk \ config \ RustDesk2 . toml " rendezvous_server = 'IPADDRESS' `n nat_type = 1 `n serial = 0 `n `n [options] `n custom-rendezvous-server = 'IPADDRESS' `n key = 'KEY=' `n relay-server = 'IPADDRESS' `n api-server = 'https://IPADDRESS' "
Remove-Item C: \ Windows \ ServiceProfiles \ LocalService \ AppData \ Roaming \ RustDesk \ config \ RustDesk2 . toml
New-Item C: \ Windows \ ServiceProfiles \ LocalService \ AppData \ Roaming \ RustDesk \ config \ RustDesk2 . toml
Set-Content C: \ Windows \ ServiceProfiles \ LocalService \ AppData \ Roaming \ RustDesk \ config \ RustDesk2 . toml " rendezvous_server = 'IPADDRESS' `n nat_type = 1 `n serial = 0 `n `n [options] `n custom-rendezvous-server = 'IPADDRESS' `n key = 'KEY=' `n relay-server = 'IPADDRESS' `n api-server = 'https://IPADDRESS' "
net start rustdesk
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
net start rustdesk > null
2023-08-24 10:25:07 +02:00
cd $env:ProgramFiles \ RustDesk \
$rustdesk_id = ( . \ RustDesk . exe - -get -id | more )
Write-Output " $rustdesk_id "
Write-Output " $rustdesk_pw "
2022-08-17 17:56:31 +02:00
Stop-Process -Name RustDesk -Force > null
Start-Service -Name RustDesk > null