================================================================================
  MIRACLE BOOT - WINDOWS RECOVERY ENVIRONMENT (WinRE) QUICK START GUIDE
================================================================================

This guide provides commands to use when you're in Windows Recovery Environment
(WinRE) accessed via Shift+F10 command prompt or Advanced Startup Options.

================================================================================
SECTION 1: ENABLE INTERNET/NETWORK IN WINRE/WINPE (QUICK FIX)
================================================================================

⚠️ IMPORTANT: If internet is not working, run these commands FIRST before
   downloading Miracle Boot from GitHub.

QUICK FIX - Run these commands in order:
----------------------------------------

1. List all network interfaces:
   netsh interface show interface

2. Enable ALL network adapters (run each command):
   netsh interface set interface name="Ethernet" admin=enable
   netsh interface set interface name="Wi-Fi" admin=enable
   netsh interface set interface name="Wireless Network Connection" admin=enable
   
   (Replace with actual interface names from step 1)

3. Release and renew IP (force DHCP):
   netsh interface ip set address name="Ethernet" dhcp
   netsh interface ip set dns name="Ethernet" dhcp
   ipconfig /release
   ipconfig /renew

4. Configure DNS (if DHCP doesn't work):
   netsh interface ip set dns name="Ethernet" static 8.8.8.8
   netsh interface ip add dns name="Ethernet" 8.8.4.4 index=2

5. Test connectivity:
   ping 8.8.8.8
   ping google.com

If ping fails, try these additional steps:
------------------------------------------

6. Start network services (if available):
   net start Dnscache
   net start Dhcp

7. Reset network stack:
   netsh winsock reset
   netsh int ip reset

8. Restart network adapter:
   netsh interface set interface name="Ethernet" admin=disable
   netsh interface set interface name="Ethernet" admin=enable

9. Check firewall (disable if blocking):
   netsh advfirewall set allprofiles state off

10. Test again:
    ping 8.8.8.8
    ping 1.1.1.1

If still no internet:
---------------------
- Network drivers may not be loaded in WinPE
- Try using USB drive method (see Section 2, Option C)
- Or use another device to download and copy via USB

================================================================================
SECTION 2: DOWNLOAD MIRACLE BOOT FROM GITHUB (WINPE/WINRE)
================================================================================

⚠️ PREREQUISITE: Ensure internet is working (see Section 1 above)

Option A: Using PowerShell (Recommended - Works in WinPE/WinRE)
---------------------------------------------------------------
1. Navigate to target drive (D:, E:, or USB drive):

    cd D:\
    # or
    cd E:\

2. Download using .NET WebClient (most reliable in WinPE):

    powershell -Command "$client = New-Object System.Net.WebClient; $client.DownloadFile('https://github.com/eltonaguiar/MiracleBoot_v7_1_1/archive/refs/heads/main.zip', 'D:\MiracleBoot.zip')"

3. Extract the ZIP file:

    powershell -Command "Expand-Archive -Path 'D:\MiracleBoot.zip' -DestinationPath 'D:\' -Force"

4. Navigate to extracted folder:

    cd D:\MiracleBoot_v7_1_1-main

Alternative: One-line download and extract:
-------------------------------------------
    powershell -Command "$client = New-Object System.Net.WebClient; $client.DownloadFile('https://github.com/eltonaguiar/MiracleBoot_v7_1_1/archive/refs/heads/main.zip', 'D:\MiracleBoot.zip'); Expand-Archive -Path 'D:\MiracleBoot.zip' -DestinationPath 'D:\' -Force; cd 'D:\MiracleBoot_v7_1_1-main'"

If download fails, check internet:
-----------------------------------
    ping 8.8.8.8
    ping github.com

If ping fails, see Section 1 for network troubleshooting.

Option B: Using Git Clone (If Git is available in WinPE)
----------------------------------------------------------
Some WinPE builds include Git. If available:

    cd D:\
    git clone https://github.com/eltonaguiar/MiracleBoot_v7_1_1.git
    cd MiracleBoot_v7_1_1

Note: Most WinPE builds don't include Git. Use Option A instead.

Option C: Manual Download (Using Another Device)
------------------------------------------------
1. On a working computer/phone, download from:
   https://github.com/eltonaguiar/MiracleBoot_v7_1_1/archive/refs/heads/main.zip
   
   Or visit the repository directly:
   https://github.com/eltonaguiar/MiracleBoot_v7_1_1
   Then click "Code" → "Download ZIP"

2. Copy the ZIP file to a USB drive

3. In WinRE, copy from USB to a local drive:

    xcopy E:\MiracleBoot.zip D:\ /Y
    cd /d D:\
    powershell -Command "Expand-Archive -Path 'D:\MiracleBoot.zip' -DestinationPath 'D:\' -Force"
    cd /d D:\MiracleBoot_v7_1_1-main

================================================================================
SECTION 3: RUN MIRACLE BOOT IN WINRE
================================================================================

After downloading and extracting Miracle Boot:

Step 1: Navigate to the Miracle Boot folder
--------------------------------------------
    cd /d D:\MiracleBoot_v7_1_1-main
    # or wherever you extracted it

Step 2: Launch Miracle Boot
----------------------------
Option A: Using the CMD launcher (Recommended)
    RunMiracleBoot.cmd

Option B: Using PowerShell directly
    powershell -ExecutionPolicy Bypass -File MiracleBoot.ps1

Option C: If PowerShell is not available, use CMD fallback
    cd Helper
    WinRepairCore.cmd

Step 3: Follow the Menu
------------------------
- Miracle Boot will detect you're in WinRE and show the Text User Interface (TUI)
- Use the menu options to diagnose and repair your Windows installation
- Key options:
  * Z) Precision Boot Scan - Diagnose boot issues
  * O) ONE-CLICK PRECISION FIXER - Automated repair
  * A) Advanced Diagnostics - Full boot diagnosis
  * D) System File Repair - SFC/DISM repair
  * E) Disk Repair - CHKDSK

================================================================================
SECTION 4: COMMON WINRE COMMANDS
================================================================================

List all drives and volumes (with labels):
    diskpart
    list volume
    exit

View drive volume labels (PowerShell):
    Get-Volume | Format-Table DriveLetter, FileSystemLabel, Size, HealthStatus

View drive volume labels (CMD):
    vol C:
    vol D:
    vol E:

Check which drive has Windows:
    dir C:\Windows
    dir D:\Windows
    dir E:\Windows

View boot configuration:
    bcdedit /enum all

Scan for Windows installations:
    bootrec /scanos

Rebuild BCD:
    bootrec /rebuildbcd

Fix boot sector:
    bootrec /fixboot

Fix MBR:
    bootrec /fixmbr

Repair boot files:
    bcdboot C:\Windows

Mount EFI Partition (for UEFI systems):
    Method 1: Using diskpart (Recommended)
    ---------------------------------------
    diskpart
    list disk
    select disk 0
    list partition
    select partition 1    (or the EFI partition number, usually partition 1)
    assign letter=S
    exit

    Then verify:
    dir S:\EFI\Microsoft\Boot

    If S: is occupied, try T:, U:, V:, W:, Y:, or Z:

    Method 2: Using mountvol (Alternative)
    ---------------------------------------
    First, create an empty directory or use an existing drive letter:
    mkdir S:\  (if S: doesn't exist)
    
    Then mount EFI to that path:
    mountvol S: /S
    
    Note: mountvol /S mounts the EFI System Partition to the specified drive letter.
    The drive letter must already exist or be assigned first using diskpart.

Unmount EFI Partition (when done):
    Method 1: Using diskpart
    ------------------------
    diskpart
    select disk 0
    select partition 1
    remove letter=S
    exit

    Method 2: Using mountvol
    --------------------------
    mountvol S: /D

(Replace C: with your actual Windows drive letter, and S: with your preferred EFI drive letter)

================================================================================
SECTION 5: TROUBLESHOOTING
================================================================================

Problem: "PowerShell is not recognized"
Solution: WinRE may not have PowerShell. Use RunMiracleBoot.cmd which will
          fall back to CMD mode, or try:
          X:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

Problem: "Cannot download from GitHub"
Solution: 
  1. Check internet: ping 8.8.8.8
  2. Try downloading on another device and copying via USB
  3. Use the manual download method (Option C above)

Problem: "Access denied" errors
Solution: Some commands require administrator privileges. In WinRE, you should
          already be running as administrator, but if issues persist, try
          running commands from the X: drive (WinRE system drive).

Problem: "Script execution is disabled"
Solution: Use the -ExecutionPolicy Bypass flag:
          powershell -ExecutionPolicy Bypass -File MiracleBoot.ps1

================================================================================
SECTION 6: QUICK REFERENCE - COPY/PASTE COMMANDS (WINPE/WINRE)
================================================================================

# STEP 1: Enable Internet (run these one by one):
netsh interface show interface
netsh interface set interface name="Ethernet" admin=enable
netsh interface set interface name="Wi-Fi" admin=enable
netsh interface ip set address name="Ethernet" dhcp
netsh interface ip set dns name="Ethernet" static 8.8.8.8
ipconfig /renew
ping 8.8.8.8

# STEP 2: Download Miracle Boot from GitHub:
cd D:\
powershell -Command "$client = New-Object System.Net.WebClient; $client.DownloadFile('https://github.com/eltonaguiar/MiracleBoot_v7_1_1/archive/refs/heads/main.zip', 'D:\MiracleBoot.zip'); Expand-Archive -Path 'D:\MiracleBoot.zip' -DestinationPath 'D:\' -Force; cd 'D:\MiracleBoot_v7_1_1-main'"

# STEP 3: Run Miracle Boot:
RunMiracleBoot.cmd

# Alternative: If internet doesn't work, use USB method:
# 1. Download on another device: https://github.com/eltonaguiar/MiracleBoot_v7_1_1/archive/refs/heads/main.zip
# 2. Copy ZIP to USB drive
# 3. In WinPE: xcopy E:\MiracleBoot.zip D:\ /Y
# 4. Extract: powershell -Command "Expand-Archive -Path 'D:\MiracleBoot.zip' -DestinationPath 'D:\' -Force"
# 5. Run: cd D:\MiracleBoot_v7_1_1-main && RunMiracleBoot.cmd

================================================================================
NOTES
================================================================================

- Replace D:\ with your actual drive letter (could be C:, E:, F:, etc.)
- In WinRE, your Windows drive might be D: or E: instead of C:
- Always check which drive has Windows before running repair commands
- The X: drive is the WinRE system drive - don't modify it
- USB drives are usually E:, F:, or G: depending on your setup

For more help, see README.md in the Miracle Boot folder.

================================================================================
