1. Verify and Restore Environment Variables
- Press Win + R, type sysdm.cpl, go to Advanced β Environment Variables.
- Restore missing variables like Path, TEMP, and SystemRoot.
- Ensure critical paths such as C:\Windows\System32 are intact in the Path variable.
2. Perform System File Repair
- Use SFC and DISM to repair system corruption:
sfc /scannow
DISM /Online /Cleanup-Image /RestoreHealth
3. Perform a Clean Boot
To rule out third-party services or startup items:
- Run msconfig β Services tab β Hide Microsoft Services β Disable all.
- Reboot and test the system.
4. Check the Registry for Corrupt Entries
- Open regedit, backup your registry.
- Navigate to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
- Ensure essential keys exist and point to valid paths.
5. Scan for Malware
Malware can damage system environment variables. Run a deep scan using Windows Defender or trusted third-party antivirus tools.
6. Restore System to a Previous Point
- Go to Control Panel β Recovery β Open System Restore.
- Choose a restore point before the issue begins to undo system changes.
7. Reinstall or Repair Windows (Advanced)
If all else fails and the environment is too corrupted, perform a repair install using the Windows ISO:
- Mount the ISO, run setup.exe, and choose "Keep files and apps."