Improve RustDesk exe detection and add MSI install logging
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
a80d04b01a
commit
97701505c3
@@ -37,10 +37,11 @@ function Install-RustDesk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Silent MSI install
|
# 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 {
|
Try {
|
||||||
Start-Process -FilePath "msiexec.exe" `
|
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
|
-Wait
|
||||||
Start-Sleep -Seconds 10
|
Start-Sleep -Seconds 10
|
||||||
}
|
}
|
||||||
@@ -53,21 +54,50 @@ function Install-RustDesk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Locate the installed exe
|
# Locate the installed exe
|
||||||
$rustdeskExe = "$rustdeskInstallDir\$($rustdeskMsi -replace '\.msi$', '.exe')"
|
# First try: registry InstallLocation from the MSI uninstall entry
|
||||||
if (-not (Test-Path $rustdeskExe)) {
|
$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..."
|
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' } |
|
Where-Object { $_.Name -match 'rustdesk|scoutit|remotesupport' } |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
if ($found) {
|
if ($found) {
|
||||||
$rustdeskExe = $found.FullName
|
$rustdeskExe = $found.FullName
|
||||||
Write-Host "Found exe at: $rustdeskExe"
|
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
|
$exeDir = Split-Path $rustdeskExe
|
||||||
|
|
||||||
# Install service if not present
|
# Install service if not present
|
||||||
|
|||||||
@@ -28,10 +28,11 @@ Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ── Silent MSI install ────────────────────────────────────────────────────────
|
# ── 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 {
|
Try {
|
||||||
Start-Process -FilePath "msiexec.exe" `
|
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
|
-Wait
|
||||||
Start-Sleep -Seconds 10
|
Start-Sleep -Seconds 10
|
||||||
}
|
}
|
||||||
@@ -44,21 +45,50 @@ Finally {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ── Locate the installed exe ──────────────────────────────────────────────────
|
# ── Locate the installed exe ──────────────────────────────────────────────────
|
||||||
$rustdeskExe = "$rustdeskInstallDir\$($rustdeskMsi -replace '\.msi$', '.exe')"
|
# First try: registry InstallLocation from the MSI uninstall entry
|
||||||
if (-not (Test-Path $rustdeskExe)) {
|
$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..."
|
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' } |
|
Where-Object { $_.Name -match 'rustdesk|scoutit|remotesupport' } |
|
||||||
Select-Object -First 1
|
Select-Object -First 1
|
||||||
if ($found) {
|
if ($found) {
|
||||||
$rustdeskExe = $found.FullName
|
$rustdeskExe = $found.FullName
|
||||||
Write-Host "Found exe at: $rustdeskExe"
|
Write-Host "Found exe at: $rustdeskExe"
|
||||||
} else {
|
|
||||||
Write-Error "Could not locate RustDesk exe after install."
|
|
||||||
exit 1
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 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-Error "Could not locate RustDesk exe after install. Check MSI log: $msiLog"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
$exeDir = Split-Path $rustdeskExe
|
$exeDir = Split-Path $rustdeskExe
|
||||||
|
|
||||||
# ── Install service if not present ────────────────────────────────────────────
|
# ── Install service if not present ────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user