diff --git a/1-estudio-Install-TacticalRMM-and-RustDesk.ps1 b/1-estudio-Install-TacticalRMM-and-RustDesk.ps1 index 89989eb..2356e5d 100644 --- a/1-estudio-Install-TacticalRMM-and-RustDesk.ps1 +++ b/1-estudio-Install-TacticalRMM-and-RustDesk.ps1 @@ -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 diff --git a/2-estudio-Install-RustDesk-Standalone.ps1 b/2-estudio-Install-RustDesk-Standalone.ps1 index 49c1ea4..027d024 100644 --- a/2-estudio-Install-RustDesk-Standalone.ps1 +++ b/2-estudio-Install-RustDesk-Standalone.ps1 @@ -28,10 +28,11 @@ Catch { } # ── 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 } @@ -44,21 +45,50 @@ Finally { } # ── 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-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 # ── Install service if not present ────────────────────────────────────────────