For windows: start it in safe mode with command prompt (without ui, or even without ui and network)
eliminate the desktop, taskbar, and file explorer and run only Command Prompt or PowerShell (replacing explorer.exe with a CLI shell in the registry) or using Server Core/Nano Server principles