Files
powershell-scripts/dncfix/vtmfix.ps1
cproudlock 7c30939234 Add maintenance toolkit, DNC/OnGuard utilities
- Add Invoke-RemoteMaintenance.ps1: Remote maintenance tasks (DISM, SFC, disk cleanup, etc.)
- Add DNC/, dncfix/, edncfix/: DNC configuration utilities
- Add onguard/: OnGuard integration scripts
- Add tools/: Additional utility scripts
- Update remote-execution/README.md with maintenance toolkit docs

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 13:08:08 -05:00

65 lines
2.0 KiB
PowerShell

# Real-time file watcher to strip 0xFF from .pun files
# Watches folder and cleans files as soon as they're created/modified
$watchFolder = "C:\Dnc_Files\Q" # Change to your DNC program folder
$fileFilter = "*.pun" # Watch .pun files
Write-Host "Watching $watchFolder for new/modified $fileFilter files..."
Write-Host "Press Ctrl+C to stop"
# Create file system watcher
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = $watchFolder
$watcher.Filter = $fileFilter
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true
# Define what to do when file is created or changed
$action = {
$path = $Event.SourceEventArgs.FullPath
$changeType = $Event.SourceEventArgs.ChangeType
Write-Host "$(Get-Date -Format 'HH:mm:ss') - $changeType detected: $path"
# Wait a moment for file to finish writing
Start-Sleep -Milliseconds 500
try {
# Read file as bytes
$bytes = [System.IO.File]::ReadAllBytes($path)
$originalCount = $bytes.Count
# Remove all 0xFF bytes
$cleaned = $bytes | Where-Object { $_ -ne 255 }
$newCount = $cleaned.Count
# Only rewrite if we found 0xFF
if ($originalCount -ne $newCount) {
[System.IO.File]::WriteAllBytes($path, $cleaned)
$removed = $originalCount - $newCount
Write-Host " [OK] Cleaned! Removed $removed byte(s) [0xFF]" -ForegroundColor Green
} else {
Write-Host " [SKIP] No 0xFF found, file OK" -ForegroundColor Gray
}
}
catch {
Write-Host " [ERROR] $_" -ForegroundColor Red
}
}
# Register event handlers
Register-ObjectEvent -InputObject $watcher -EventName Created -Action $action
Register-ObjectEvent -InputObject $watcher -EventName Changed -Action $action
# Keep script running
try {
while ($true) {
Start-Sleep -Seconds 1
}
}
finally {
# Cleanup on exit
$watcher.Dispose()
Write-Host "`nStopped watching folder"
}