Skip to content

Commit 48db985

Browse files
committed
fix: improve DLL registration and unregistration process in install-thumbnail-handler script
1 parent 3b454fc commit 48db985

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/install-thumbnail-handler.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmpPath -UseBasicPa
4545
if (Test-Path -LiteralPath $dllPath) {
4646
Write-Host "Unregistering existing DLL..." -ForegroundColor Yellow
4747
try {
48-
& regsvr32.exe /s /u $dllPath
48+
$unregProcess = Start-Process -FilePath "regsvr32.exe" -ArgumentList "/s", "/u", "`"$dllPath`"" -Wait -PassThru -NoNewWindow
49+
if ($unregProcess.ExitCode -ne 0) {
50+
Write-Warning "Failed to unregister old DLL. Exit code: $($unregProcess.ExitCode)"
51+
}
4952
} catch {
5053
Write-Warning "Failed to unregister old DLL: $($_.Exception.Message)"
5154
}
@@ -61,9 +64,9 @@ if (!(Test-Path -LiteralPath $dllPath)) {
6164

6265
# Register the COM DLL
6366
Write-Host "Registering COM DLL with Windows..." -ForegroundColor Yellow
64-
$regResult = & regsvr32.exe /s $dllPath
65-
if ($LASTEXITCODE -ne 0) {
66-
throw "Failed to register DLL. regsvr32 returned exit code: $LASTEXITCODE"
67+
$regProcess = Start-Process -FilePath "regsvr32.exe" -ArgumentList "/s", "`"$dllPath`"" -Wait -PassThru -NoNewWindow
68+
if ($regProcess.ExitCode -ne 0) {
69+
throw "Failed to register DLL. regsvr32 returned exit code: $($regProcess.ExitCode)"
6770
}
6871

6972
Write-Host "Successfully installed and registered ltk-tex-thumb-handler $version" -ForegroundColor Green

0 commit comments

Comments
 (0)