mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2024-12-25 16:39:19 +01:00
Powershell script will now be able to automatically get the latest version from github
The function getLatest() returns an object containing the current version number and the current download link. In addition, the parameter "-wait" had to be removed from Start-Process, as the current version (1.2.3) apparently never ends if the Rustdesk service is not ended manually. Instead, a start-sleep of 20 seconds was added.
This commit is contained in:
parent
775e355fc6
commit
f81ba46944
@ -23,7 +23,7 @@ $rustdesk_cfg="configstring"
|
||||
|
||||
############################## Bitte nicht unterhalb dieser Zeile bearbeiten ###################################
|
||||
|
||||
# Wird als Administrator ausgeführt und bleibt im aktuellen Verzeichnis
|
||||
# Als Administrator ausführen und im selben Verzeichnis bleiben
|
||||
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)
|
||||
@ -33,11 +33,57 @@ if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
|
||||
}
|
||||
}
|
||||
|
||||
# Diese Funktion gibt die neuste Versionsnummer und den Downloadlink als Objekt zurück
|
||||
function getLatest()
|
||||
{
|
||||
$Page = Invoke-WebRequest -Uri 'https://github.com/rustdesk/rustdesk/releases/latest' -UseBasicParsing
|
||||
$HTML = New-Object -Com "HTMLFile"
|
||||
try
|
||||
{
|
||||
$HTML.IHTMLDocument2_write($Page.Content)
|
||||
}
|
||||
catch
|
||||
{
|
||||
$src = [System.Text.Encoding]::Unicode.GetBytes($Page.Content)
|
||||
$HTML.write($src)
|
||||
}
|
||||
|
||||
# Aktueller Beispiellink: https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.exe
|
||||
$Downloadlink = ($HTML.Links | Where {$_.href -match '(.)+\/rustdesk\/rustdesk\/releases\/download\/\d{1}.\d{1,2}.\d{1,2}(.{0,3})\/rustdesk(.)+x86_64.exe'} | select -first 1).href
|
||||
|
||||
# bugfix - Manchmal muss man das "about:" ersetzen
|
||||
$Downloadlink = $Downloadlink.Replace('about:', 'https://github.com')
|
||||
|
||||
$Version = "unknown"
|
||||
if ($Downloadlink -match './rustdesk/rustdesk/releases/download/(?<content>.*)/rustdesk-(.)+x86_64.exe')
|
||||
{
|
||||
$Version = $matches['content']
|
||||
}
|
||||
|
||||
if ($Version -eq "unknown" -or $Downloadlink -eq "")
|
||||
{
|
||||
Write-Output "FEHLER: Version oder Downloadlink nicht gefunden."
|
||||
Exit
|
||||
}
|
||||
|
||||
# Zurückgebendes Objekt erstellen
|
||||
$Result = New-Object PSObject -Property
|
||||
@{
|
||||
Version = $Version
|
||||
Downloadlink = $Downloadlink
|
||||
}
|
||||
|
||||
return($Result)
|
||||
}
|
||||
|
||||
$RustDeskOnGitHub = getLatest
|
||||
|
||||
|
||||
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
|
||||
|
||||
if ($rdver -eq "1.2.3")
|
||||
if ($rdver -eq $RustDeskOnGitHub.Version)
|
||||
{
|
||||
Write-Output "RustDesk $rdver ist die neueste Version"
|
||||
Write-Output "RustDesk $rdver ist die neuste Version"
|
||||
Exit
|
||||
}
|
||||
|
||||
@ -48,8 +94,9 @@ if (!(Test-Path C:\Temp))
|
||||
|
||||
cd C:\Temp
|
||||
|
||||
Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.exe" -Outfile "rustdesk.exe"
|
||||
Start-Process .\rustdesk.exe --silent-install -wait
|
||||
Invoke-WebRequest $RustDeskOnGitHub.Downloadlink -Outfile "rustdesk.exe"
|
||||
Start-Process .\rustdesk.exe --silent-install
|
||||
Start-Sleep -seconds 20
|
||||
|
||||
$ServiceName = 'Rustdesk'
|
||||
$arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
@ -58,7 +105,7 @@ if ($arrService -eq $null)
|
||||
{
|
||||
Write-Output "Installieren des Dienstes"
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
Start-Process .\rustdesk.exe --install-service -wait -Verbose
|
||||
Start-Process .\rustdesk.exe --install-service
|
||||
Start-Sleep -seconds 20
|
||||
}
|
||||
|
||||
|
@ -33,9 +33,55 @@ if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
|
||||
}
|
||||
}
|
||||
|
||||
# This function will return the latest version and download link as an object
|
||||
function getLatest()
|
||||
{
|
||||
$Page = Invoke-WebRequest -Uri 'https://github.com/rustdesk/rustdesk/releases/latest' -UseBasicParsing
|
||||
$HTML = New-Object -Com "HTMLFile"
|
||||
try
|
||||
{
|
||||
$HTML.IHTMLDocument2_write($Page.Content)
|
||||
}
|
||||
catch
|
||||
{
|
||||
$src = [System.Text.Encoding]::Unicode.GetBytes($Page.Content)
|
||||
$HTML.write($src)
|
||||
}
|
||||
|
||||
# Current example link: https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.exe
|
||||
$Downloadlink = ($HTML.Links | Where {$_.href -match '(.)+\/rustdesk\/rustdesk\/releases\/download\/\d{1}.\d{1,2}.\d{1,2}(.{0,3})\/rustdesk(.)+x86_64.exe'} | select -first 1).href
|
||||
|
||||
# bugfix - sometimes you need to replace "about:"
|
||||
$Downloadlink = $Downloadlink.Replace('about:', 'https://github.com')
|
||||
|
||||
$Version = "unknown"
|
||||
if ($Downloadlink -match './rustdesk/rustdesk/releases/download/(?<content>.*)/rustdesk-(.)+x86_64.exe')
|
||||
{
|
||||
$Version = $matches['content']
|
||||
}
|
||||
|
||||
if ($Version -eq "unknown" -or $Downloadlink -eq "")
|
||||
{
|
||||
Write-Output "ERROR: Version or download link not found."
|
||||
Exit
|
||||
}
|
||||
|
||||
# Create object to return
|
||||
$Result = New-Object PSObject -Property
|
||||
@{
|
||||
Version = $Version
|
||||
Downloadlink = $Downloadlink
|
||||
}
|
||||
|
||||
return($Result)
|
||||
}
|
||||
|
||||
$RustDeskOnGitHub = getLatest
|
||||
|
||||
|
||||
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
|
||||
|
||||
if ($rdver -eq "1.2.3")
|
||||
if ($rdver -eq $RustDeskOnGitHub.Version)
|
||||
{
|
||||
Write-Output "RustDesk $rdver is the newest version"
|
||||
Exit
|
||||
@ -48,8 +94,9 @@ if (!(Test-Path C:\Temp))
|
||||
|
||||
cd C:\Temp
|
||||
|
||||
Invoke-WebRequest "https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.exe" -Outfile "rustdesk.exe"
|
||||
Start-Process .\rustdesk.exe --silent-install -wait
|
||||
Invoke-WebRequest $RustDeskOnGitHub.Downloadlink -Outfile "rustdesk.exe"
|
||||
Start-Process .\rustdesk.exe --silent-install
|
||||
Start-Sleep -seconds 20
|
||||
|
||||
$ServiceName = 'Rustdesk'
|
||||
$arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
@ -58,7 +105,7 @@ if ($arrService -eq $null)
|
||||
{
|
||||
Write-Output "Installing service"
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
Start-Process .\rustdesk.exe --install-service -wait -Verbose
|
||||
Start-Process .\rustdesk.exe --install-service
|
||||
Start-Sleep -seconds 20
|
||||
}
|
||||
|
||||
|
@ -31,9 +31,54 @@ if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
|
||||
}
|
||||
}
|
||||
|
||||
# Bu fonksiyon en son sürüm numarasını ve indirme bağlantısını bir nesne olarak döndürür
|
||||
function getLatest()
|
||||
{
|
||||
$Page = Invoke-WebRequest -Uri 'https://github.com/rustdesk/rustdesk/releases/latest' -UseBasicParsing
|
||||
$HTML = New-Object -Com "HTMLFile"
|
||||
try
|
||||
{
|
||||
$HTML.IHTMLDocument2_write($Page.Content)
|
||||
}
|
||||
catch
|
||||
{
|
||||
$src = [System.Text.Encoding]::Unicode.GetBytes($Page.Content)
|
||||
$HTML.write($src)
|
||||
}
|
||||
|
||||
# Güncel örnek linki: https://github.com/rustdesk/rustdesk/releases/download/1.2.3/rustdesk-1.2.3-x86_64.exe
|
||||
$Downloadlink = ($HTML.Links | Where {$_.href -match '(.)+\/rustdesk\/rustdesk\/releases\/download\/\d{1}.\d{1,2}.\d{1,2}(.{0,3})\/rustdesk(.)+x86_64.exe'} | select -first 1).href
|
||||
|
||||
# bugfix - Bazen "about:" kısmını değiştirmeniz gerekir.
|
||||
$Downloadlink = $Downloadlink.Replace('about:', 'https://github.com')
|
||||
|
||||
$Version = "unknown"
|
||||
if ($Downloadlink -match './rustdesk/rustdesk/releases/download/(?<content>.*)/rustdesk-(.)+x86_64.exe')
|
||||
{
|
||||
$Version = $matches['content']
|
||||
}
|
||||
|
||||
if ($Version -eq "unknown" -or $Downloadlink -eq "")
|
||||
{
|
||||
Write-Output "HATA: Sürüm veya indirme bağlantısı bulunamadı."
|
||||
Exit
|
||||
}
|
||||
|
||||
# Zurückgebendes Objekt erstellen
|
||||
$Result = New-Object PSObject -Property
|
||||
@{
|
||||
Version = $Version
|
||||
Downloadlink = $Downloadlink
|
||||
}
|
||||
|
||||
return($Result)
|
||||
}
|
||||
|
||||
$RustDeskOnGitHub = getLatest
|
||||
|
||||
$rdver = ((Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\RustDesk\").Version)
|
||||
|
||||
if($rdver -eq "1.2.2")
|
||||
if($rdver -eq $RustDeskOnGitHub.Version)
|
||||
{
|
||||
write-output "RustDesk $rdver en yeni sürüm"
|
||||
|
||||
@ -46,14 +91,18 @@ If (!(Test-Path c:\Temp)) {
|
||||
|
||||
cd c:\Temp
|
||||
|
||||
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
|
||||
powershell Invoke-WebRequest $RustDeskOnGitHub.Downloadlink -Outfile "rustdesk.exe"
|
||||
Start-Process .\rustdesk.exe --silent-install
|
||||
Start-Sleep -seconds 20
|
||||
|
||||
$ServiceName = 'Rustdesk'
|
||||
$arrService = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
|
||||
|
||||
if ($arrService -eq $null)
|
||||
{
|
||||
Write-Output "Hizmetin yüklenmesi"
|
||||
cd $env:ProgramFiles\RustDesk
|
||||
Start-Process .\rustdesk.exe --install-service
|
||||
Start-Sleep -seconds 20
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user