From f4279fb962aaf9265db1b3ac53993037665da111 Mon Sep 17 00:00:00 2001 From: amd64fox <62529699+amd64fox@users.noreply.github.com> Date: Sat, 18 Apr 2026 18:12:47 +0300 Subject: [PATCH] Add clipboard copy for diagnostics --- scripts/DL_Diag.ps1 | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/scripts/DL_Diag.ps1 b/scripts/DL_Diag.ps1 index 1f2a0c2..a4e0bde 100644 --- a/scripts/DL_Diag.ps1 +++ b/scripts/DL_Diag.ps1 @@ -129,6 +129,30 @@ function Invoke-WebClientStep { } } +function Copy-TextToClipboard { + param( + [Parameter(Mandatory = $true)] + [string]$Text + ) + + try { + if (Get-Command Set-Clipboard -ErrorAction SilentlyContinue) { + Set-Clipboard -Value $Text -ErrorAction Stop + return $true + } + + if (Get-Command clip.exe -ErrorAction SilentlyContinue) { + $Text | clip.exe + return ($LASTEXITCODE -eq 0) + } + } + catch { + return $false + } + + return $false +} + function Get-DiagnosticArchitecture { $arch = $env:PROCESSOR_ARCHITEW6432 if ([string]::IsNullOrWhiteSpace($arch)) { @@ -336,7 +360,25 @@ else { Invoke-WebClientStep -Title 'WebClient direct stable' -Uri $directUrl +$finalOutputLines = New-Object 'System.Collections.Generic.List[string]' +$finalOutputLines.Add('----- BEGIN DIAGNOSTICS -----') | Out-Null + +foreach ($line in $reportLines) { + $finalOutputLines.Add($line) | Out-Null +} + +$finalOutputLines.Add('----- END DIAGNOSTICS -----') | Out-Null +$finalOutputText = [string]::Join([Environment]::NewLine, $finalOutputLines) +$clipboardCopied = Copy-TextToClipboard -Text $finalOutputText + Write-Host +if ($clipboardCopied) { + Write-Host 'Diagnostics copied to clipboard' -ForegroundColor Green +} +else { + Write-Host 'Clipboard copy failed, copy the text below manually' -ForegroundColor Yellow +} + Write-Host '----- BEGIN DIAGNOSTICS -----' -ForegroundColor Cyan foreach ($line in $reportLines) {