Files
claudetools/remove-pause-echo.ps1
Mike Swanson f9c3a5d3a9 debug: Add parameter debugging and remove redundant PAUSE messages
Changes:
1. Added DEBUG output at script start to show %1 and %2 parameters
2. Removed 46 redundant "ECHO Press any key..." lines before PAUSE
   - DOS 6.22 PAUSE command already displays this message
   - No need for custom echo with same text

Debug output will show:
  DEBUG: Parameter 1 = [value]
  DEBUG: Parameter 2 = [value]

This will help diagnose why machine name parameter is not being
received when running: T:\DEPLOY.BAT TS-4R

Files modified:
- DEPLOY.BAT: Added debug lines 18-22, removed 10 ECHO lines
- UPDATE.BAT: Removed 7 ECHO lines
- CTONW.BAT: Removed 8 ECHO lines
- NWTOC.BAT: Removed 6 ECHO lines
- REBOOT.BAT: Removed 4 ECHO lines
- STAGE.BAT: Removed 6 ECHO lines
- CHECKUPD.BAT: Removed 2 ECHO lines
- DOSTEST.BAT: Removed 2 ECHO lines
- AUTOEXEC.BAT: Removed 1 ECHO line

Deployed to D2TESTNAS: /data/test/DEPLOY.BAT

Next test: Run T:\DEPLOY.BAT TS-4R and check DEBUG output

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-19 17:22:58 -07:00

47 lines
1.7 KiB
PowerShell

# Remove redundant ECHO lines before PAUSE
# DOS 6.22 PAUSE already displays "Press any key to continue..."
$BATFiles = Get-ChildItem *.BAT | Where-Object {
$_.Name -notlike "*_FROM_*" -and
$_.Name -notlike "*_TEST*" -and
$_.Name -notlike "*_VERIFY*" -and
$_.Name -notlike "*_CHECK*" -and
$_.Name -notlike "*_MONITOR*"
}
Write-Host "[INFO] Removing redundant ECHO before PAUSE" -ForegroundColor Cyan
Write-Host ""
$TotalRemoved = 0
foreach ($File in $BATFiles) {
Write-Host "Processing: $($File.Name)" -ForegroundColor White
$Content = Get-Content $File.FullName -Raw
# Remove "ECHO Press any key..." lines immediately before PAUSE
# Pattern: ECHO Press any key...\r?\n\s*PAUSE
$OriginalContent = $Content
$Content = $Content -replace 'ECHO Press any key[^\r\n]*\r?\n(\s*)PAUSE', '$1PAUSE'
if ($Content -ne $OriginalContent) {
$RemovedCount = ([regex]::Matches($OriginalContent, 'ECHO Press any key')).Count - ([regex]::Matches($Content, 'ECHO Press any key')).Count
Set-Content $File.FullName $Content -NoNewline
Write-Host " [OK] Removed $RemovedCount redundant ECHO lines" -ForegroundColor Green
$TotalRemoved += $RemovedCount
} else {
Write-Host " [OK] No redundant ECHO lines found" -ForegroundColor Green
}
}
Write-Host ""
Write-Host "[SUCCESS] Removed $TotalRemoved redundant ECHO lines" -ForegroundColor Green
Write-Host ""
Write-Host "DOS 6.22 PAUSE displays:" -ForegroundColor Cyan
Write-Host " 'Press any key to continue . . .'" -ForegroundColor White
Write-Host ""
Write-Host "No need for ECHO before PAUSE unless:" -ForegroundColor Cyan
Write-Host " - Custom message needed (not 'Press any key...')" -ForegroundColor White
Write-Host ""