Random Command Prompt Opens and Closes: 7 Ways to Fix It

A Clean Boot may get rid of the random Command Prompt pop ups

by Claire Moraa
Claire Moraa
Claire Moraa
Author
Claire likes to think she's got a knack for solving problems and improving the quality of life for those around her. Driven by the forces of rationality, curiosity,... read more
Reviewed by Alex Serban
Alex Serban
Alex Serban
Windows Server & Networking Expert
After moving away from the corporate work-style, Alex has found rewards in a lifestyle of constant analysis, team coordination and pestering his colleagues. Holding an MCSA Windows Server... read more
Affiliate Disclosure
  • The Command Prompt is a powerful Windows tool that can execute commands when you need to.
  • When it randomly opens and closes without being called upon, it can be a worrying situation that indicates an underlying problem.

XINSTALL BY CLICKING THE DOWNLOAD FILE
To fix various PC problems, we recommend Restoro PC Repair Tool:
This software will repair common computer errors, protect you from file loss, malware, hardware failure and optimize your PC for maximum performance. Fix PC issues and remove viruses now in 3 easy steps:

  1. Download Restoro PC Repair Tool that comes with Patented Technologies (patent available here).
  2. Click Start Scan to find Windows issues that could be causing PC problems.
  3. Click Repair All to fix issues affecting your computer's security and performance
  • Restoro has been downloaded by 0 readers this month.

The Command Prompt is a tool used by the Windows operating system to execute commands and run programs. It’s a simple and effective way to run programs directly from Windows.

But even though it’s useful, sometimes you might find that the Command Prompt opens and closes randomly and sometimes on startup. If this happens often enough, it can be extremely frustrating.

Why does my CMD randomly pop up and close?

When the Command Prompt opens and closes randomly, it may indicate that there is a problem with your computer. The following are some of the reasons why this issue might occur:

  • Too many programs open at once – If you have other programs running at the same time, they could be interfering with each other and causing issues with the Command Prompt.
  • Virus infection – Viruses are able to infect any part of your computer, including the Command Prompt. That’s why a great antivirus solution that is up-to-date should always be installed on your PC.
  • Maintenance tasks – Some maintenance tasks will automatically open a Command Prompt window as part of their routine. If this is the case, then you don’t need to worry about it.
  • Third-party interference – If you’re using a third-party program to open the Command Prompt, such as a batch file or a script, it’s possible that the command used in the file is causing issues with Windows Command Prompt.
  • Corrupt system file – A damaged Windows system file or corrupted Windows registry entry can make it difficult for some programs to run correctly, such as the Command Prompt.

How can I fix the Command Prompt opening and closing randomly?

Before attempting the slightly technical steps, try the following:

  • Close any other applications first before opening up another one in this way and see if that helps solve the problem.
  • Close all Command Prompt windows that may be open before trying again.
  • Finally, try restarting your PC and see if the Command Prompt behaves the same way. If your PC fails to restart, refer to our guide.

1. Run the netstat command

  1. Hit the Windows key, type cmd in the search bar, and click Run as administrator.cmd-admin hp printer won't scan
  2. Type the following command and press Enter: cmd /k netstat

2. Scan for viruses

  1. Press the Windows key, search Windows Security and click Open.
  2. Select Virus & threat protection.
  3. Next, press Quick scan under Current threats.
  4. If you don’t find any threats, proceed to perform a full scan by clicking on Scan options just below Quick scan.
  5. Click on Full scan to perform a deep scan of your PC.Full scan
  6. Wait for the process to finish and restart your system.

If you want to get a thorough PC scan of malware, we recommend using a third-party antivirus, ESET Internet Security, for it has some of the most advanced malware security features.

Get ESET Internet Security

3. Run the DISM and SFC commands

  1. Hit the Windows key, type cmd in the search bar, and click Run as administrator.cmd-admin hp printer won't scan
  2. Type the following command and press Enter: Dism /Online /Cleanup-Image /RestoreHealthdism
  3. Wait for the command to be executed then type the next one and hit Enter: Sfc /scannowsfc scannow command

4. Run the CHKDSK command

  1. Hit the Windows key, type cmd in the search bar, and click Run as administrator.cmd-admin hp printer won't scan
  2. Type the following command, replace the C letter with your drive’s letter, and press Enter: chkdsk C: /fchkdsk

5. Disable Task Scheduler triggers

  1. Hit the Windows key, type Task Scheduler in the search bar, and click Open.
  2. Navigate to Task Scheduler Library on the left.
  3. Check for any suspicious triggers. (Most users complained OneDrive was a common trigger). 
  4. Right-click on it and select Disable.
  5. Restart your PC.

Expert tip:

SPONSORED

Some PC issues are hard to tackle, especially when it comes to corrupted repositories or missing Windows files. If you are having troubles fixing an error, your system may be partially broken.
We recommend installing Restoro, a tool that will scan your machine and identify what the fault is.
Click here to download and start repairing.

Task Scheduler is a Windows component that lets you schedule tasks. You can use Task Scheduler to run programs or scripts at scheduled times. However, by default, this feature is enabled with a number of triggers that launch on boot or when you log in.

These triggers may be required for some applications, but if you don’t need them, disabling them can free up resources and improve performance.

6. Update System Environment Variable

  1. Hit the Search icon, type environment in the search bar, and click to open the Edit the system environment variables.
  2. The System Properties dialog will pop up, click on the Advanced tab and select Environment Variables at the bottom.
  3. Under System variables, navigate to path and click on Edit.
  4. Now click on New to create a new entry and add C:\Windows\SysWow64\, then click OK.
  5. Restart your PC.

7. Perform a clean boot

  1. Hit the Windows key, type msconfig, and open System Configuration.
  2. Switch to the Services tab.
  3. Select Hide all Microsoft services.
  4. Click on the Disable all button then hit the Apply button to save the changes.
  5. Go back and click on the Startup tab and select Open Task Manager.
  6. In the Startup tab of the Task Manager, Disable all the Enabled startup items.
  7. Close Task Manager and restart your PC.

A clean boot is a way to troubleshoot a computer that may be running improperly. If you suspect that an application or program is causing the problem, the clean boot can help by disabling the software and allowing Windows to run without it.

Alternatively, if your computer is having trouble starting up normally, then starting it in Safe Mode can help identify what’s causing the issue.

Hopefully, the annoying Command Prompt opening randomly is long gone by now and your computer has been restored to normalcy. Elsewhere, users complained of not being able to run CMD as administrator so if you were experiencing this issue, don’t hesitate to refer to our helpful guide.

Also, if the CMD prompt keeps popping up, we have a remedy for the situation in our dedicated article.

We love your feedback so don’t hesitate to leave us a comment down below on what solution worked for you.

Still having issues? Fix them with this tool:

SPONSORED

If the advices above haven't solved your issue, your PC may experience deeper Windows problems. We recommend downloading this PC Repair tool (rated Great on TrustPilot.com) to easily address them. After installation, simply click the Start Scan button and then press on Repair All.

This article covers:Topics: