Black Command Prompt cmd.exe window keeps popping up on startup

A black cmd.exe window on startup means a startup app, Startup folder shortcut, scheduled task or service is launching Command Prompt, so turn off the entry that starts it.

This guide covers each of those locations, a clean boot to isolate the cause, a malware scan, and the related problems of a blank white window, a missing Startup tab and Discord launching at sign-in.

Black Command Prompt cmd.exe window keeps popping up on startup
System Configuration lists services by manufacturer and status; select Hide all Microsoft services to leave only third-party entries before you select Disable all. (Image: Microsoft Q&A)

Command Prompt cmd.exe keeps popping up on startup

Start with the startup list, because it is the quickest place to check and the change is easy to reverse. You can also disable startup programs from Task Manager if you prefer.

  1. Select Start, then Settings, then Apps, then Startup.
  2. Note which apps are set to On, so you can restore them later.
  3. Set any app you do not recognize or need at sign-in to Off.
  4. Restart the PC and sign in.
  5. Wait a minute or two. If the window does not appear, the entry you turned off was the cause.

If the window still appears, the entry is somewhere this list does not show. Work through the sections below in order.

Why does my CMD randomly pop up on startup?

The window itself is the command interpreter, cmd.exe. It only opens because something else starts it, so the fix is always to find that something.

What starts cmd.exe When it runs Where to check
Startup app At sign-in Settings > Apps > Startup, or the Startup apps tab in Task Manager
Startup folder shortcut At sign-in shell:startup and shell:common startup in the Run box
Run or RunOnce registry value At sign-in Autoruns, or the registry keys listed further down this page
Scheduled task At sign-in or on a timer, which can look random schtasks /query /fo LIST /v, or Task Scheduler
Non-Microsoft service At boot The Services tab in System Configuration
Malware Any of the above A Microsoft Defender scan

Black window keeps popping up and disappearing in Windows 11

A window that flashes and closes is usually a command that finished. cmd /c carries out its command and then exits the command processor, so the window lasts only as long as the job.

Scheduled tasks can run that kind of command on a timer as well as at sign-in. List them with this command in Command Prompt, and you can use Task Scheduler to browse the same tasks in a window.

schtasks /query /fo LIST /v

/query lists scheduled tasks, /fo LIST shows them as a readable list and /v adds each task's advanced properties, including the program it runs.

You should see: A long list of tasks. Look for any non-Microsoft task whose program is cmd.exe, or a .bat or .cmd file.

To turn off a task you found, run schtasks /change /tn "Task name" /DISABLE from an elevated Command Prompt. Put quotation marks around the name if it contains spaces.

How to find what opens cmd.exe at startup with Autoruns

Autoruns is Microsoft's own Sysinternals tool for this job. It shows startup folder items, Run and RunOnce keys, services and scheduled tasks in one window, and Task Manager cannot do that.

  1. Download Autoruns from the Sysinternals Autoruns page, extract the ZIP file and run Autoruns.
  2. Open the Options menu and turn on Hide Signed Microsoft Entries to focus on third-party items.
  3. Switch to the tab for logon entries, then to the tab for scheduled tasks.
  4. Look for entries that run cmd.exe, or a .bat or .cmd file.
  5. Select an entry and use Properties or Jump to Entry to see the file and where it is registered.
  6. Clear the entry's check box to disable it, then restart and test.

Clearing the check box is reversible, so use it first. Use the Delete menu item only after the PC has run normally without that entry.

How to remove cmd.exe from the Startup folder in Windows 11

A shortcut or batch file in a Startup folder runs every time someone signs in. Windows has one folder per user and one Startup folder for everyone on the PC.

  1. Right-click Start and select Run.
  2. Type shell:startup and press Enter to open the folder for your account.
  3. Delete any shortcut or script you do not recognize.
  4. Open Run again, type shell:common startup and press Enter to open the folder for all users.
  5. Delete anything unwanted there, then restart the PC.

Windows startup registry keys that can open Command Prompt

Each value under a Run key is a command line that Windows runs at sign-in. Back up the registry before you change it, because an incorrect edit can severely damage the system. Autoruns shows the same entries and is the safer route.

Registry key What it does
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run Runs the command every time this user signs in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce Runs the command once for this user, then the value is deleted
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run Runs the command every time any user signs in
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunOnce Runs the command once, when a member of the Administrators group signs in
HKEY_CURRENT_USER\Software\Microsoft\Command Processor value AutoRun Runs before other commands each time cmd.exe starts, unless /d is used

The same AutoRun value can also exist under HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor. It does not open a window by itself, but it can run unwanted commands whenever something else starts cmd.exe.

How to stop black Command Prompt popping up with a clean boot

A clean boot starts Windows with only Microsoft services and no startup apps, which shows whether third-party software is responsible. You need an administrator account. Microsoft warns that System Configuration can leave a PC unusable if network policy settings interfere, so on a work PC ask your administrator first.

  1. Search for msconfig and open System Configuration.
  2. On the Services tab, select Hide all Microsoft services, select Disable all, then select Apply.
  3. On the Startup tab, select Open Task Manager.
  4. On the Startup apps tab, select each Enabled item and select Disable, writing down what you changed.
  5. Close Task Manager, select OK in System Configuration, then restart.
  6. If the window is gone, re-enable the upper half of the disabled services and restart.
  7. Keep halving the list until the window returns, then repeat the test with startup items.

Once you know the item, update or uninstall that program, or contact its maker. If the window appears even during a clean boot, the problem might be a Microsoft service, so repair the system files as shown further down.

Disable all turns off every non-Microsoft service, so do not stay in this state longer than the test takes.

Stop black Command Prompt popping up by searching msconfig for System Configuration
A clean boot starts here: type msconfig in Start search, then open System Configuration from the Best match results. (Image: Microsoft)

How to undo a clean boot in Windows 11

  1. Search for msconfig and open System Configuration.
  2. On the General tab, select Normal Startup.
  3. On the Services tab, clear Hide all Microsoft services, select Enable all, then select Apply.
  4. On the Startup tab, select Open Task Manager and enable the startup apps you disabled earlier.
  5. Select OK, then select Restart when prompted.
Black Command Prompt window on startup: undo clean boot in System Configuration General tab
Select Normal Startup on this tab, then go to the Services tab and select Enable all. (Image: Microsoft Q&A)

Scan for malware when a black cmd window keeps popping up

An unknown entry that keeps coming back deserves a scan. Run Microsoft Defender from the Windows Security app.

  1. Open Windows Security and select Virus & threat protection.
  2. Select Quick scan and wait for the result.
  3. Select Scan options, then run a Full scan if the quick scan finds nothing and the window continues.
  4. Save your open files, then select Microsoft Defender Offline scan under Scan options.
  5. Let the PC restart. The deep scan that follows can catch malware a regular scan misses.

A Microsoft Defender Offline scan restarts the PC, so run it when you can leave the machine alone for a while.

Scan for malware when a black cmd window keeps popping up in Windows Security
Select Quick scan first, then open Scan options for a Full scan or the Microsoft Defender Offline scan. (Image: Microsoft)

C:\Windows\System32\cmd.exe black window on startup

That path in the title bar is the Windows command processor, cmd.exe, and it shows whenever something starts that program. It does not tell you what launched it, so use the sections above to find the source.

If no startup entry explains the window and scans come back clean, repair the system files. Run these in order from an elevated Command Prompt, starting with DISM.exe /Online /Cleanup-image /Restorehealth and then the command below.

sfc /scannow

System File Checker scans protected Windows files and replaces damaged ones. DISM runs first because it repairs the files System File Checker relies on.

You should see: Windows Resource Protection did not find any integrity violations. or Windows Resource Protection found corrupt files and successfully repaired them.

cmd.exe black window on startup repair with sfc /scannow in Administrator Command Prompt
Run this after DISM from an elevated Command Prompt; the window reports a verification percentage while the scan runs. (Image: Microsoft)

Blank white window opens every time I log into Windows 11

A blank white window that opens by itself at every sign-in needs the same search, because something in the startup locations is launching it. Test startup apps in halves, which is faster than testing one at a time.

  1. Right-click Start and select Task Manager.
  2. Select the Startup apps tab and note every item marked Enabled.
  3. Disable the upper half of those items, then restart.
  4. If the window is gone, the cause is in the half you disabled. If it stays, the cause is in the other half.
  5. Repeat with the remaining half until one item is left.
  6. Update or uninstall that app, or contact its maker, then re-enable the others.

If no startup item is responsible, use the clean boot steps above to test services as well.

Startup tab missing from Task Manager in Windows 11

Task Manager in current Windows versions calls this tab Startup apps, so a search for a tab named Startup can come up empty. The Startup tab in System Configuration does not list apps either. It offers Open Task Manager instead.

  1. Right-click Start and select Task Manager.
  2. Select Startup apps to see the list.
  3. Select an app, then select Enable or Disable.
  4. If you cannot reach the tab, select Start > Settings > Apps > Startup for the same on and off control.
Startup tab in Task Manager listing apps with Enabled and Disabled status
Older Windows versions label this tab Startup, while current versions call it Startup apps; select an app, then select Disable. (Image: Microsoft)

Stop Discord from launching at startup in Windows 11

Windows can stop Discord from starting automatically through its startup list, without changing anything inside Discord. You can still open Discord yourself whenever you want it.

  1. Select Start > Settings > Apps > Startup.
  2. Find Discord in the list and set it to Off.
  3. If it is not listed there, right-click Start, select Task Manager and open Startup apps.
  4. Select Discord, then select Disable.
  5. Restart the PC to test the change.

How to tell if a scheduled task still opens cmd.exe in Windows 11

A clean restart alone does not prove the fix, because a timer-based task can fire hours later. Check that the task is actually off.

Get-ScheduledTask -TaskName "Task name"

Run this in PowerShell with the name of the task you disabled. It shows the task's folder, name and current state. Add -TaskPath "\Folder\" if the task sits in a subfolder, because the default is the root folder.

You should see: Disabled in the State column. If it says Ready or Running, the task can still open the window.

Black Command Prompt window on startup FAQ

Why does a black Command Prompt keep popping up?

Something on the PC is starting cmd.exe, usually a startup app, a Startup folder shortcut, a Run registry value or a scheduled task. Malware can use the same locations. Find the entry with Task Manager or Autoruns, then disable it.

Is the Windows black DOS window the same as Command Prompt?

Yes. The black text window people call a DOS window is Command Prompt, which runs the Windows command interpreter, cmd.exe. Other console programs can open a similar black window, so read the title bar to see which program it names.

Why does the black window keep popping up and disappearing?

The window closes as soon as its command finishes. A command run with cmd /c exits the command processor when it is done, so the window can vanish almost at once. Scheduled tasks and logon scripts can both run this way.

What does C:\Windows\System32\cmd.exe in the title bar mean?

It names the program that opened, which is the Windows command interpreter. The title does not show which app, task or script launched it. Use Autoruns or the scheduled task list to trace the source of the window.

Is a black cmd window on startup a virus?

Not always, because many legitimate apps and scheduled tasks run commands at sign-in. Treat an entry you cannot identify as suspicious, and run a Microsoft Defender quick scan followed by a Microsoft Defender Offline scan.

How do I find which program opens cmd.exe at startup?

Run Autoruns from Microsoft Sysinternals and hide signed Microsoft entries, then look for items that run cmd.exe or a batch file. Use Jump to Entry to see where each one is registered, and clear its check box to test.

Philip Celasco

Philip is a Texas-based technology writer and IT administrator at Techdows.com with more than 10 years of experience creating practical content for everyday users and professionals. He specializes in web browsers, particularly Chromium-based platforms such as Google Chrome, Microsoft Edge, Brave, and Opera. Through his work as an IT administrator, Philip has hands-on experience managing devices, configuring browser policies, troubleshooting software and network issues, and helping people resolve problems that affect productivity and security. His articles are based on practical testing and real-world technical experience. He covers browser settings, extensions, performance problems, privacy controls, security features, and Windows troubleshooting. Outside work, Philip enjoys the quieter side of life in Texas and stepping away from the screen when he can. He has two kids, two cats and loves to play golf with his mother during the weekends.

Leave a Reply

Your email address will not be published. Required fields are marked *