.NET Framework - Check if Windows booted in Normal or Safe Mode

Heres a really small code sample on how to check which mode Windows was booted up in (Normal or Safe Mode). This works in .NET 1.x and 2.0.

'  This code checks to see which mode Windows has booted up in.  
Select Case System.Windows.Forms.SystemInformation.BootMode
Case BootMode.FailSafe
  '  The computer was booted using only the basic files and drivers.  
  '  This is the same as Safe Mode  
Case BootMode.FailSafeWithNetwork
  '  The computer was booted using the basic files, drivers, and services necessary to start networking.  
  '  This is the same as Safe Mode with Networking  
Case BootMode.Normal
  '  The computer was booted in Normal mode.  
End Select
Chris Pietschmann
Chris Pietschmann
Microsoft MVP | App Innovation Leader | Azure, AI & DevOps Architect | HashiCorp Ambassador | Author
I'm a Practice Leader, App Innovation specialist, solution architect, developer, SRE, trainer, and author with 25+ years of experience helping enterprises turn AI, app modernization, cloud architecture, and DevOps into real business outcomes.