Add local rustdesk.exe support and improve installation script
parent
28d0566d74
commit
4ef9247c04
|
|
@ -19,6 +19,11 @@ if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
|
|||
}
|
||||
}
|
||||
|
||||
# Проверка наличия rustdesk.exe в текущей папке
|
||||
$localRustDesk = Join-Path $PSScriptRoot "rustdesk.exe"
|
||||
$rustdeskExistsLocally = Test-Path $localRustDesk
|
||||
|
||||
if (-not $rustdeskExistsLocally) {
|
||||
# Checks for the latest version of RustDesk
|
||||
$url = 'https://www.github.com//rustdesk/rustdesk/releases/latest'
|
||||
$request = [System.Net.WebRequest]::Create($url)
|
||||
|
|
@ -26,12 +31,15 @@ $response = $request.GetResponse()
|
|||
$realTagUrl = $response.ResponseUri.OriginalString
|
||||
$RDLATEST = $realTagUrl.split('/')[-1].Trim('v')
|
||||
echo "RustDesk $RDLATEST is the latest version."
|
||||
} else {
|
||||
$RDLATEST = "local" # Устанавливаем фиктивную версию для локального файла
|
||||
}
|
||||
|
||||
# Checks the version of RustDesk installed.
|
||||
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
|
||||
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\" -ErrorAction SilentlyContinue).Version)
|
||||
|
||||
# Skips to inputting the configuration if the latest version of RustDesk is already installed.
|
||||
if ($rdver -eq "$RDLATEST") {
|
||||
if ($rdver -eq $RDLATEST -and -not $rustdeskExistsLocally) {
|
||||
echo "RustDesk $rdver is already installed."
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
echo "Inputting configuration now."
|
||||
|
|
@ -80,6 +88,7 @@ if ($rdver -eq "$RDLATEST") {
|
|||
echo ""
|
||||
echo "..............................................."
|
||||
echo "RustDesk ID: $rustdesk_id"
|
||||
echo "Password: $rustdesk_pw"
|
||||
echo "..............................................."
|
||||
echo ""
|
||||
echo "Press Enter to open RustDesk."
|
||||
|
|
@ -93,9 +102,16 @@ if (!(Test-Path C:\ProgramData\RustDesk)) {
|
|||
}
|
||||
|
||||
cd C:\ProgramData\RustDesk
|
||||
|
||||
if ($rustdeskExistsLocally) {
|
||||
echo "Found local rustdesk.exe, using it for installation."
|
||||
Copy-Item -Path $localRustDesk -Destination ".\rustdesk.exe" -Force
|
||||
} else {
|
||||
echo "Downloading RustDesk version $RDLATEST."
|
||||
powershell Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/$RDLATEST/rustdesk-$RDLATEST-x86_64.exe" -Outfile "rustdesk.exe"
|
||||
echo "Installing RustDesk version $RDLATEST."
|
||||
}
|
||||
|
||||
echo "Installing RustDesk."
|
||||
Start-Process .\rustdesk.exe --silent-install
|
||||
Start-Sleep -Seconds 10
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue