Improve RustDesk exe detection and add MSI install logging

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
uhlwoogi
2026-04-15 10:44:06 +00:00
co-authored by Claude Sonnet 4.6
parent a80d04b01a
commit 97701505c3
2 changed files with 76 additions and 16 deletions
+38 -8
View File
@@ -37,10 +37,11 @@ function Install-RustDesk {
}
# Silent MSI install
Write-Host "Installing ScoutIT Remote Support client silently..."
$msiLog = "$env:SystemRoot\Temp\estudio-scoutit-remotesupport-install.log"
Write-Host "Installing ScoutIT Remote Support client silently (log: $msiLog)..."
Try {
Start-Process -FilePath "msiexec.exe" `
-ArgumentList "/i `"$msiPath`" /qn /norestart CREATEDESKTOPSHORTCUTS=`"N`" INSTALLPRINTER=`"N`"" `
-ArgumentList "/i `"$msiPath`" /qn /norestart /l*v `"$msiLog`" CREATEDESKTOPSHORTCUTS=`"N`" INSTALLPRINTER=`"N`"" `
-Wait
Start-Sleep -Seconds 10
}
@@ -53,21 +54,50 @@ function Install-RustDesk {
}
# Locate the installed exe
$rustdeskExe = "$rustdeskInstallDir\$($rustdeskMsi -replace '\.msi$', '.exe')"
if (-not (Test-Path $rustdeskExe)) {
# First try: registry InstallLocation from the MSI uninstall entry
$uninstallKeys = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*',
'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*'
)
$rustdeskExe = $null
foreach ($key in $uninstallKeys) {
$entry = Get-ItemProperty $key -ErrorAction SilentlyContinue |
Where-Object { $_.DisplayName -match 'scoutit|remotesupport|rustdesk' -or
$_.Publisher -match 'scoutit|rustdesk' } |
Select-Object -First 1
if ($entry -and $entry.InstallLocation) {
$candidate = Get-ChildItem $entry.InstallLocation -Filter '*.exe' -ErrorAction SilentlyContinue |
Select-Object -First 1
if ($candidate) {
$rustdeskExe = $candidate.FullName
Write-Host "Found exe via registry: $rustdeskExe"
break
}
}
}
# Second try: search Program Files and Program Files (x86)
if (-not $rustdeskExe) {
Write-Host "Searching for RustDesk exe in Program Files..."
$found = Get-ChildItem 'C:\Program Files' -Recurse -Filter '*.exe' -ErrorAction SilentlyContinue |
$found = Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' -Recurse -Filter '*.exe' -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match 'rustdesk|scoutit|remotesupport' } |
Select-Object -First 1
if ($found) {
$rustdeskExe = $found.FullName
Write-Host "Found exe at: $rustdeskExe"
} else {
Write-Warning "Could not locate RustDesk exe. Skipping service and ID steps."
return
}
}
# Last resort: list what the MSI actually installed so we can identify the exe
if (-not $rustdeskExe) {
Write-Warning "Could not locate RustDesk exe. Listing Program Files for diagnosis:"
Get-ChildItem 'C:\Program Files', 'C:\Program Files (x86)' -ErrorAction SilentlyContinue |
Where-Object { $_.LastWriteTime -gt (Get-Date).AddMinutes(-5) } |
ForEach-Object { Write-Host " $($_.FullName)" }
Write-Warning "Could not locate RustDesk exe. Skipping service and ID steps. Check MSI log: $msiLog"
return
}
$exeDir = Split-Path $rustdeskExe
# Install service if not present