Several users have reported that Command Prompt keeps crashing on Windows systems. As users open the Command Prompt window, it opens and closes immediately. This issue could be caused due to damaged or missing system files. Apart from that, a third-party program conflict. a corrupted user profile and malware infection can also be the reasons for this issue.
Command Prompt opens and closes immediately
If Command Prompt crashes or closes instantly after opening it on your Windows PC, you can use the following solutions to fix the issue:
- Restart your computer.
- Scan and remove malware from your PC.
- Perform an SFC scan to repair corrupted system files.
- Configure Environment Variable.
- Create a new user account.
- Uninstall a conflicting program.
- Reset Windows.
Command Prompt keeps crashing in Windows 11/10
1] Restart your computer
You can try rebooting your computer if Command Prompt keeps crashing on your PC. It will clear temporary system errors and glitches, and resolve the problem for you. So, you can definitely restart your computer before heading onto advanced fixes.
2] Scan and remove malware from your PC
If your computer is infected with viruses or malware, you will likely experience this issue. Hence, you must run a virus scan on your computer and eliminate/quarantine any potential threat to your system.
To do that, open the Windows Security app using the Search function. Now, go to the Virus & threat protection tab and then click on the Scan options button. After that, choose the type of virus scans you want to perform from Quick scan, Full scan, Custom scan, and Offline scan, and press the Scan now button. It will then start scanning your computer for viruses. Once done, you can remove the detected malware from your computer. If you use a third-party antivirus like Avast, AVG, etc., you can use similar steps to run a virus scan.
If you have a 3rd-party antivirus software installed, use it to scan your PC at boot time or in Safe Mode.
Read: Can’t run Command Prompt as administrator
3] Perform an SFC scan to repair corrupted system files
This issue might be triggered due to corrupted or missing system files. Hence, if the scenario is applicable, you can run Windows inbuilt tool called System File Checker (SFC) to fix damaged system files. SFC scan is usually run through Command Prompt. However, you can also use Windows PowerShell to perform an SFC scan. Here are the steps you can use:
First, open Windows PowerShell as an administrator; search for PowerShell, hover the mouse over the PowerShell app, and then choose Run as administrator.
Now, execute the below command in the PowerShell window and let the scan run:
SFC /scannow
Once the scan is complete, you can reboot your computer and then use Command Prompt.
If this does not help, you may need to repair a potentially corrupted system image using the DISM Tool.
4] Configure Environment Variable
A missing variable could be a reason for Command Prompt crashes. So, if the scenario applies, you can configure the environment variable accordingly to fix the issue. Here are the steps to do that:
- First, open Run using Win+R and then enter sysdm.cpl to open the System Properties window.
- Now, go to the Advanced tab and then click on the Environment Variables button.
- After that, under the System Variables section, click on the Path field.
- Next, press the Edit button and then click on the New button.
- Then, enter the C:\Windows\SysWow64 path and then press Enter.
- Finally, press the OK button to save changes and then reboot your computer.
Remember to creat a system restore point before you do this.
5] Create a new user account
You might be dealing with this issue because of a corrupted user profile. Hence, in that case, make a new user account and then see if the issue is fixed. Here’s how you can do that:
- Firstly, launch the Settings app using Win+I and then navigate to the Accounts tab.
- After that, press the Family & other users option and click on the Add account button.
- Next, type the email address for your new account on the next prompt.
- Now, click on the Next button and follow the prompted instructions to complete the process.
- When done, sign out and then login back with your new account.
- Finally, open Command Prompt and then check if the issue is resolved.
6] Uninstall a conflicting program
If there is a third-party software conflict that is causing Command Prompt to crash, you can uninstall the program to fix the issue. In case you have started experiencing this issue after installing a specific program, remove it and then check if the problem is fixed.
You can also perform a clean boot and see if the problem is resolved. Here’s how you can do that:
- First, open Run using Win+R and enter msconfig in it to open the System Configuration window.
- After that, move to the Services tab, checkmark the checkbox called Hide all Microsoft services, and press the Disable all button to turn off third-party services.
- Now, go to the Startup tab, click on the Open Task Manager button, and disable your startup apps.
- Next, in the System Configuration window, click on the OK button and restart your PC.
- On the next startup, open Command Prompt and check if the problem is fixed.
- If yes, you can start enabling services one by one and analyze which one is causing the problem.
- Once you have analyzed the culprit, uninstall the program to fix the issue permanently.
If this method doesn’t help, we have one more fix that you can use.
Read: Command Prompt keeps popping up on Startup
7] Reset Windows
The last thing you can do is reset your Windows. There might be some system corruption that is causing the issue. In that case, you can reset your Windows to its original state. It will clear all the modifications done to the system. However, you can keep your personal files and data before resetting your PC. Here are the steps to do that:
- First, open the Settings app using Win+I and go to the System tab.
- Now, click on the Recovery option from the left-side pane.
- Next, press the Reset PC button.
- In the prompted dialog, you can either choose the Keep my files option or Remove everything and then tap on OK.
- After that, follow the prompted instructions and reinstall Windows.
- Once done, restart your PC and see if Command Prompt is working without any issues.
Read: Command Prompt closes immediately after opening batch file
What to do if CMD is not working?
If Command Prompt is not working or opening at all on your computer, you can open Command Prompt using your File Explorer or Task Manager. If that doesn’t help, you can run an SFC scan through PowerShell to fix the corrupted system files that might be causing this issue. Besides that, you can open Command Prompt in Safe Mode, perform a system restore to go back to a previous healthy state, or use a new user account to open CMD.
Now read: Registry Editor not opening, crashing or stopped working .