|
1 | 1 | # Portable Sysinternals System Tester |
2 | | -# Created by Pacific Northwest Computers - 2025 |
| 2 | +# Created by Pacific Northwest Computers - 2026 |
3 | 3 | # Complete Production Version - v2.4 |
4 | 4 |
|
5 | 5 | param([switch]$AutoRun) |
@@ -1217,7 +1217,9 @@ function Test-Power { |
1217 | 1217 | } catch { $lines += "No battery (desktop)" } |
1218 | 1218 |
|
1219 | 1219 | if ($script:IsAdmin) { |
1220 | | - $report = Join-Path $ScriptRoot "energy-report.html" |
| 1220 | + $reportsDir = Join-Path $ScriptRoot "Reports" |
| 1221 | + if (!(Test-Path $reportsDir)) { New-Item -ItemType Directory -Path $reportsDir -Force | Out-Null } |
| 1222 | + $report = Join-Path $reportsDir "energy-report.html" |
1221 | 1223 | Write-Host "Generating energy report ($script:ENERGY_DURATION sec)..." -ForegroundColor Yellow |
1222 | 1224 | powercfg /energy /output $report /duration $script:ENERGY_DURATION 2>&1 | Out-Null |
1223 | 1225 | if (Test-Path $report) { |
@@ -1332,19 +1334,32 @@ function Test-WindowsUpdate { |
1332 | 1334 | function New-Report { |
1333 | 1335 | Write-Host "`nGenerating reports..." -ForegroundColor Cyan |
1334 | 1336 |
|
1335 | | - # Test write access |
1336 | | - $testFile = Join-Path $ScriptRoot "writetest_$([guid]::NewGuid().ToString('N')).tmp" |
| 1337 | + # Ensure Reports subfolder exists |
| 1338 | + $ReportsDir = Join-Path $ScriptRoot "Reports" |
| 1339 | + if (!(Test-Path $ReportsDir)) { |
| 1340 | + try { |
| 1341 | + New-Item -ItemType Directory -Path $ReportsDir -Force | Out-Null |
| 1342 | + Write-Host "Created Reports folder: $ReportsDir" -ForegroundColor DarkGray |
| 1343 | + } catch { |
| 1344 | + Write-Host "ERROR: Cannot create Reports folder: $ReportsDir" -ForegroundColor Red |
| 1345 | + Write-Host " $($_.Exception.Message)" -ForegroundColor Red |
| 1346 | + return |
| 1347 | + } |
| 1348 | + } |
| 1349 | + |
| 1350 | + # Test write access to Reports folder |
| 1351 | + $testFile = Join-Path $ReportsDir "writetest_$([guid]::NewGuid().ToString('N')).tmp" |
1337 | 1352 | try { |
1338 | 1353 | "test" | Out-File -FilePath $testFile -ErrorAction Stop |
1339 | 1354 | Remove-Item $testFile -ErrorAction Stop |
1340 | 1355 | } catch { |
1341 | | - Write-Host "ERROR: Cannot write to $ScriptRoot" -ForegroundColor Red |
| 1356 | + Write-Host "ERROR: Cannot write to Reports folder: $ReportsDir" -ForegroundColor Red |
1342 | 1357 | return |
1343 | 1358 | } |
1344 | 1359 |
|
1345 | 1360 | $timestamp = Get-Date -Format "yyyyMMdd_HHmmss" |
1346 | | - $cleanPath = Join-Path $ScriptRoot "SystemTest_Clean_$timestamp.txt" |
1347 | | - $detailedPath = Join-Path $ScriptRoot "SystemTest_Detailed_$timestamp.txt" |
| 1361 | + $cleanPath = Join-Path $ReportsDir "SystemTest_Clean_$timestamp.txt" |
| 1362 | + $detailedPath = Join-Path $ReportsDir "SystemTest_Detailed_$timestamp.txt" |
1348 | 1363 |
|
1349 | 1364 | # Calculate stats |
1350 | 1365 | $success = ($TestResults | Where-Object {$_.Status -eq "SUCCESS"}).Count |
|
0 commit comments