The persistent Command Prompt (CMD) appearing unexpectedly is more than annoying—it can disrupt workflows, expose sensitive sessions to others, or even hide behind it. The root causes vary: a misconfigured shortcut, a faulty autostart entry, or corrupted system settings trigger its relentless appearance. Here’s how to stop it for good, with step-by-step fixes that work in Windows 10/11.

What You'll Need

  • A working Windows PC (10 or 11)
  • Admin rights for most steps (run as Administrator for critical changes)
  • Access to Task Manager (Ctrl+Shift+Esc) or Task View (Win+Tab)
  • Notepad or a text editor to inspect shortcuts
  • Optional: Registry Editor (for advanced users only—back up first!)

Step-by-Step Fixes

  1. Close all open CMD instances. Press Ctrl+Shift+Esc to open Task Manager, find all "cmd.exe" processes, and force-close them. If CMD stays open after closing one, right-click its task bar icon and select End task. This prevents new instances from launching during the fix.
  2. Disable CMD shortcuts via Taskbar. Right-click the taskbar, hover over Taskbar Settings, and under Taskbar Behaviors, uncheck "Use the new taskbar to start and switch to apps" (if present). Alternatively:
    1. Right-click the taskbar, select New taskbar item.
    2. Choose Command Prompt (if listed) and delete it.
    3. If not listed, manually delete any "Command Prompt" shortcuts from:
      • Desktop: View > Hidden items to see hidden shortcuts
      • Start Menu: Win+S → All apps → search for "cmd"
      • Startup folder: Win+R → type shell:startup → delete shortcuts here
    If CMD still appears, proceed to Step 4.
  3. Remove autostart entries.
    1. Press Win+R, type shell:startup and press Enter. Delete any "cmd.exe" shortcuts or duplicate shortcuts.
    2. Open Task Manager (Ctrl+Shift+Esc), go to Startup tab. Disable any entries labeled "Command Prompt."
    3. Search for "Task Manager" in Start Menu, go to Startup tab, and click Startup to disable problematic entries.
  4. Check for rogue registry entries.
    1. Press Win+R, type regedit (press Enter), and back up the registry by exporting:
      • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
      • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    2. Search for keys named cmd.exe, Command Prompt, or Windows Terminal in the Run and RunOnce folders.
    3. If found, delete them. Do not edit entries directly—back up first!
    If you don’t know what to back up, skip this step unless CMD persists after Step 3.
  5. Repair or reset the Command Prompt shortcut.
    1. Find the original CMD shortcut (default location: C:\Windows\System32\cmd.exe). Right-click it, Properties, and check the Shortcut tab.
    2. Under Target:, ensure no extra text (like a script or delay) is appended. If it has, remove anything beyond cmd.exe.
    3. Click Advanced, check Replace shortcut target if it exists, and click Apply.
  6. Update or reset Windows.
    1. Go to Settings > Windows Update > Check for updates and install all pending updates.
    2. If CMD persists, reset the Command Prompt to default:
      1. Right-click the taskbar CMD icon, select Open file location.
      2. Right-click the cmd.exe shortcut, Properties, and under Shortcut, click Browse.
      3. Navigate to C:\Windows\System32\cmd.exe (not a modified copy). Click OK.
    If Windows Update fails, reboot into Safe Mode and roll back updates.

If That Did Not Work

If CMD keeps opening after these steps, try:
  1. Scan for malware. Run Microsoft Defender Offline Scan (Settings > Windows Security > Virus & threat protection > Scan options) to check for hidden CMD-related scripts.
  2. Create a new user profile. Go to Settings > Accounts > Family & other users, add a new user, and test if CMD appears. If not, your current profile may have corrupted shortcuts.
  3. Disable Windows Terminal (if used). In Settings > Apps > Windows Terminal, set it to Disabled. If CMD still pops up, it’s a third-party app (see FAQ 5).

Common Mistakes

  • Editing the registry without backing up. Registry errors can crash Windows. Always export keys before deleting them (use File > Export in Regedit).
  • Ignoring third-party shortcuts. Apps like Notepad++ or Git Bash may create CMD shortcuts. Check their installation paths for hidden scripts.
  • Reverting to default CMD shortcuts incorrectly. Using cmd.exe as the target in a shortcut’s Properties may not restore the original behavior. Always browse to C:\Windows\System32\cmd.exe directly.
  • Forgetting to close all instances. Task Manager must show no CMD processes (Ctrl+Shift+Esc > Processes tab) before modifying shortcuts or registry keys.

Tips

  • Use Task View to monitor CMD. Press Win+Tab to see all open windows. If CMD appears, it’s not tied to the taskbar shortcut.
  • Check App Launcher shortcuts. Some apps (e.g., Visual Studio Code) launch CMD by default. Go to their settings to disable this behavior.
  • Test in Safe Mode. Boot into Safe Mode (hold Shift while clicking Restart in Settings) to rule out malware or third-party software.
  • Avoid "Run" shortcuts in File Explorer. Right-click a file in Explorer, select Open with > Choose another app, and ensure CMD is not set as default unless intentionally used.

Troubleshooting

  1. CMD opens when I log in. This suggests a Run registry key. Use Registry Editor to confirm and delete keys named cmd.exe in:
    • HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
    • HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
  2. CMD pops up after every app launch. Check for a RunOnce key in the registry, or search the startup folder for delayed scripts.
  3. CMD appears in pop-ups or tooltips. This could mean an extension or browser plugin (like Chrome’s "Open in CMD") is triggering it. Disable browser extensions or update Chrome/Firefox.
  4. I’ve rebooted multiple times; nothing works.
    1. Create a fresh user profile (Win+S → Settings > Accounts > Family & other users). If CMD doesn’t appear, your profile has corrupted settings.
    2. Use an offline backup tool (like Macrium Reflect) to restore a clean system state from before the issue started.
  5. I’m using Windows Terminal instead of classic CMD. In Settings > Apps > Windows Terminal, set it to Disabled. If CMD still pops up, it’s a third-party app (see FAQ 5).

Frequently Asked Questions

Why does CMD keep appearing even after I’ve deleted its shortcuts?

CMD may launch due to a hidden registry key, a third-party app (like VS Code or Notepad++), or a browser extension. Check the Startup tab in Task Manager and the registry for Run/RunOnce entries.

How do I stop CMD from opening when I search for it in the Start Menu?

Right-click the search bar, select Search settings, and turn off "Quick search" (if available). Alternatively, disable "Search" in Settings > Personalization > Start.

Can a virus cause CMD to open repeatedly?

Yes. Run a full antivirus scan in Safe Mode (Shift while restarting) and check for suspicious services or startup items. Third-party tools like Malwarebytes may detect hidden CMD-related scripts.

What if I accidentally deleted a CMD shortcut while fixing it?

Recreate it by right-clicking the taskbar, selecting New taskbar item, and choosing Command Prompt. If that fails, browse to C:\Windows\System32\cmd.exe and create a shortcut there.

Why does CMD open when I click a file in File Explorer?

This setting is usually under Open with > Choose another app. Select More apps > Choose another app and ensure CMD is not auto-selected for file types (e.g., `.txt`).

How can I permanently disable CMD in Windows Terminal mode?

Go to Settings > Apps > Windows Terminal, set it to Disabled, and click Save. If CMD still appears, it’s a third-party app (e.g., Git Bash, VS Code) triggering it.