Command Prompt Opens and Closes Immediately in Windows 10 - 9 Solutions

If you are troubled by the problem that Command Prompt opens and closes immediately in Windows 10, you can solve it by referring to the 9 solutions in this article. This article also provides one way to back up your system to prevent data loss.

By @Yuka Last Updated November 1, 2022

How to Stop Command Prompt Keeps Popping Up and Closing Windows 10

“Guys I just got a new laptop for 3 days without any updates installed and I'm having issues. In Windows 10 the command prompt closes as soon as it opens. I can't figure out what's causing it, as this is a new laptop and I'm sure no changes have been made to it. I'm currently looking for what's causing this problem and what should I do to stop it from happening. Any help would be greatly appreciated!”

The Windows Command Prompt (cmd.exe) provides users with a command-line interface through the Win32 console, allowing users to run programs or batch files from the command line for system administration. Normally, the Command Prompt doesn't have any problems. But at some point, it can also happen like the one mentioned in the above case, where the Command Prompt closes immediately after opening.

Considering that more and more users are troubled by this problem, the reasons for the problem and corresponding solutions are specially summarized here. First, we need to understand why the Command Prompt is having problems.

Why Does the Command Prompt Close Immediately After Opening It?

You will sometimes find CMD opens and closes immediately in Windows 10. There is no doubt that this will greatly affect your experience. So, why does the Command Prompt open and close randomly? Common reasons are as follows:

✪ Background Application Conflicts (eg Microsoft Office, Firefox) ✪ Malware Attack ✪ Windows Updates Being Installed ✪ System File Corruption ✪ Automatic Maintenance ✪ Environment Variables Paths Are Missing

9 Solutions to Fix Command Prompt Opening and Closing Immediately

Knowing the exact cause of the problem is just the beginning, the real point is: how to stop the Command Prompt from closing immediately after opening. Next, we've rounded up 9 different solutions for you to make sure you can fix this problem.

Method 1. Create A Copy of CMD.exe and Change the Name

You can try to fix this by creating a copy of cmd.exe and changing the name, which works for a lot of users.

  1. Open This PC on the desktop and navigate to Local Disk (C:) -> Windows -> System32. Find the cmd.exe application, right-click it, select Copy in the expanded menu, and paste in the original path to get a copy of cmd.exe.
  2. Right-click on the copy of cmd.exe, select Rename in the expanded menu, rename it to something else (eg prashant). Double-click to open the renamed copy of cmd.exe.

Method 2. Close Conflicting Background Apps

Applications such as Office 365 and Firefox browser are common causes of background application conflicts. So, when you are unfortunate enough to encounter the issue that the Command Prompt opens and closes immediately in Windows 10, you can try disabling the above apps to fix the issue.

♦ Disable Firefox Browser

  1. Press Ctrl + Shift + Esc key combination to open the Task Manager and switch to the Startup tab above.
  2. Find and select the Firefox browser, right-click it and select the Disable option from the expanded menu.

♦ Disable Office Components

  1. Type task scheduler in the taskbar search box to find and open the application.
  2. Find the OfficeBackgroundTaskHandler in the right window, right-click it, and disable the task in the expanded menu.

Method 3. Use Windows 10 System File Checker (SFC)

If the system file is damaged, it may also cause the problem that CMD opens and closes immediately in Windows 10. For this, you can try to fix this problem by running the Windows 10 System File Checker (SFC). This will scan the system files and image system files in Windows 10 and automatically repair the corrupted files in them.

  1. Type cmd in the search box on the taskbar, and click the Run as administrator option in the right window.
  2. Type the following command in the Command Prompt window and press Enter to execute the command. Wait for the tool to scan and repair automatically, it will take you some time.
  • sfc /scannow

  1. Type the following commands one after the other and press Enter to make sure they execute properly:
  • DISM.exe /Online /Cleanup-image /Scanhealth
  • DISM.exe /Online /Cleanup-image /Checkhealth
  • DISM.exe /Online /Cleanup-image /Restorehealth

It will take you some time to wait for the tool to automatically repair the system image files. It should be noted that the repair commands for system files and image system files can be executed separately.

Method 4. Use the CHKDSK /F Command to Fix the Error

Use the CHKDSK /F command to check and fix errors on your computer's disk, which will help you solve the Windows 10 Command Prompt closes immediately after opening.

  1. Type cmd in the search box on the taskbar, and click the Run as administrator option in the right window.
  2. Type the following command in the Command Prompt window and press Enter to execute the command, then press Y to confirm execution. Then restart the computer and wait for the automatic repair.
  • CHKDSK /F

Method 5. Delete the Auto Run Key from the Registry

According to the feedback from some users, deleting the Auto Run file in the Registry can effectively solve the problem that the Command Prompt opens and closes immediately in Windows 10. You can try this method.

  1. Use the Windows + R key combination to open the Run dialog, type regedit and press Enter to open the Registry Editor.

  1. Navigate to one of the following two paths, find and delete the file named Auto Run in the right window.
  • HKEY_CURRENT_USER\Software\Microsoft\Command Processor
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor

Method 6. Perform A Clean Boot

A clean boot will start the Windows system with the fewest drivers, which can eliminate the conflicts of third-party software to the greatest extent. This helps with the issue that Command Prompt keeps popping up and closing in Windows 10.

  1. Use the Windows + R key combination to open the Run dialog, type msconfig and press Enter to open System Configuration.

  1. Switch to the Services tab above, check the Hide all Microsoft services checkbox, and click the Disable all button.

  1. Switch to the Startup tab above and click the Open Task Manager button.

  1. In the list of started up applications, select each item in turn, right-click and select Disable.

  1. After disabling all started applications, go back to System Configuration, click OK to save the changes and restart the computer.

Method 7. Add System Environment Variable Path

As mentioned in the reason, missing environment variable paths can also cause problems in Windows 10 where Command Prompt closes immediately after opening. Since the C:\Windows\SysWow64\ path is usually missing, you need to add the missing path manually.

  1. Type Environment Variables in the taskbar search box and open System Properties. Under the Advanced tab click Environment Variables.

  1. Select PATH in the Environment Variables window and click the Edit button.

  1. Click the New button in the right sidebar, add C:\Windows\SysWow64\, and click OK to save the changes.

Method 8. Use Command to Keep CMD Open

You can get around the issue that CMD opens and closes immediately in Windows 10 by leaving CMD open, which only requires you to use a single command.

Use the Windows + R key combination to open the Run dialog, type cmd /k ipconfig /all and press Enter to execute this command.

Method 9. Update the Driver

If there is a problem with your device driver, it will show up as a yellow exclamation mark in Device Manager. At this point, you need to keep the driver in question updated to prevent the issue of Command Prompt opening and closing immediately in Windows 10.

  1. Press Windows + X key combination to open the menu, find and click Device Manager.
  2. In the Device Manager window, check for a yellow exclamation mark next to the device. If so, please update this device now. Please focus on Network adapters drivers to ensure this device driver is always up to date.

The above 9 methods can help you solve the problem that Command Prompt opens and closes immediately in Windows 10, but in order to further avoid data loss caused by malware attack and system file corruption, it is recommended that you use AOMEI Backupper Standard for system backup.

Backup Your System to Prevent Data Loss

AOMEI Backupper Standard is a free and professional system backup software that can back up your Windows 11/10/8.1/8/7/Vista/XP system with just a few simple steps. It contains all partitions related to system files, boot files (EFI system partition, recovery partition, etc.). In addition, user-installed applications and user settings are backed up.

During the system backup process, the system image backup file can be compressed to save storage space. What’s more, you can also use the Incremental Backup feature in AOMEI Backupper Standard to further save storage space. If you are a Professional user, you can also use the Differential Backup feature to improve backup efficiency.

Before using this software for system backup, you need to complete the following preparations:

▶ It is recommended to clean up the system first and delete useless temporary files to save time for system backup. So as to avoid restoring some useless temporary files to the computer when restoring the system. ▶ Download AOMEI Backupper Standard software.

Download Freeware Win 11/10/8.1/8/7/XP
Secure Download

The following are the detailed operation steps of AOMEI Backupper Standard system backup:

  1. Run AOMEI Backupper Standard, switch to the Backup tab in the left sidebar, and click the System Backup option in the right window.

  1. Select the destination path to save your system backup. In addition, you can click Task Name at the top left and change the name of your backup task to distinguish it from other backup tasks.

  1. Click the Start Backup button in the lower right corner to start the system backup.

Tips: You can also click the Options, Schedule, and Scheme options in the lower left corner. ❃ Options: You can customize the comments of the current backup task, and choose whether to enable encrypted backup and email notifications, where encrypted backup can be used in the Professional version. ❃ Schedule: You can turn on the scheduled backup function, and arrange Daily/Weekly/Monthly/Event triggers/USB plug in for system backup according to your own needs. Among them, Event triggers and USB plug in are advanced functions that can only be used in the paid version. ❃ Scheme: You can choose the backup method (Full Backup, Incremental Backup and Differential Backup), and choose whether to enable the automatic backup cleanup function. It should be noted that to use the differential backup and automatic backup cleanup functions, you need to upgrade to the advanced editions.

  1. After the backup is complete, click the Finish button.

In addition to system backup, AOMEI Backupper can also meet your other needs:

✔ You can use the Disk Backup and Partition Backup features to provide additional security for your computer. ✔ You can use the System Clone function to completely migrate the current system to another hard disk and ensure a safe boot. ✔ To further ensure disk data security, you can use the Disk Clone function to easily and completely migrate all files and data on one disk to other disks.

Conclusion

If you unfortunately encounter the problem that the Command Prompt opens and closes immediately in Windows 10, you can try the above 9 solutions in turn, which can help you solve this problem. However, it will involve malware attacks and system file corruption, which may affect the normal operation of the system and cause data loss.

Therefore, it is recommended to use AOMEI Backupper Standard for system backup to protect and restore data. AOMEI Backupper Standard is simple and convenient to operate, allowing you to easily backup your system. In addition, the software can also meet your File Backup and File Sync needs, allowing you to use the Windows system with greater confidence.