Compare commits

...

2 Commits

1 changed files with 27 additions and 12 deletions

View File

@ -19,19 +19,27 @@ if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
}
}
# Checks for the latest version of RustDesk
$url = 'https://www.github.com//rustdesk/rustdesk/releases/latest'
$request = [System.Net.WebRequest]::Create($url)
$response = $request.GetResponse()
$realTagUrl = $response.ResponseUri.OriginalString
$RDLATEST = $realTagUrl.split('/')[-1].Trim('v')
echo "RustDesk $RDLATEST is the latest version."
# Проверка наличия 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)
$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."
@ -94,9 +102,16 @@ if (!(Test-Path C:\ProgramData\RustDesk)) {
}
cd C:\ProgramData\RustDesk
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."
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."
Start-Process .\rustdesk.exe --silent-install
Start-Sleep -Seconds 10