What can you do if Command Prompt pops up and closes in Windows 11? Now, you come to the right place. In this post, MiniTool Partition Wizard summarizes several effective and easy ways to fix the issue.
Since the release of Windows 11, many users encounter various issues like Valorant FPS drops, Windows hello not working, screen flickering, and the one discussed here. Why Command Prompt pops up and closes on Windows 11? According to a survey, the issue is often related to missing Environment Variable path. Besides, other factors like badly migrated tasks, conflicting background Office tasks, crypto-mining AutoRun key, and even malware infection are responsible for the problem. Luckily, there are several effective troubleshooting methods.
Fix 1. Perform a DISM Repair
If you recently upgraded to Windows 11 from an older version like Windows 10, you may encounter some issues because there’s no utility in the new OS to run migrated background tasks. In this case, you can try performing a DISM repair to clean any unwanted tasks.
Step 1. Press Win + R keys to open the Run box, and then type wt in it and press Ctrl + Shift + Enter to access the Windows Terminal window with admin rights.
Step 2. Click on Yes in the User Account Control window to confirm it.
Step 3. In the elevated Windows Terminal window, type the following command in order and hit Enter after each one to execute the DISM scan.
- DISM.exe /Online /Cleanup-image /Scanhealth
- DISM.exe /Online /Cleanup-image /Restorehealth
- DISM.exe /online /cleanup-image /startcomponentcleanup
Once done, reboot your computer and check if the Command Prompt opens and closes in Windows 11.
Fix 2. Manually Add the Missing Environment Variable Path
Another command reason for Command Prompt pops up and closes in Windows 11 is due to the Environment variable path being missing or configured improperly. Here you can follow the steps below to add the missing Environment variable path manually.
Step 1. Open the Run box again, and then type sysdm.cpl in it and hit Enter.
Step 2. In the System Properties window, go to the Advanced tab and click on Environment Variables at the bottom.
Step 3. Locate the System variables section, and then select Path from the list and click on Edit.
Step 4. In the pop-up window, click on New to create a new entry, and then name it C:WindowsSysWow64 and add it as the new Environment Variable path.
Step 5. Click on OK to save changes.
Now, restart your computer and see if the Command Prompt opening up and closing automatically Windows 11 issue gets solved.
Fix 3. Disable Any Office Tasks
Some users reported that the Command Prompt flashes and closes Windows 11 when a background task belonging to the Office suite is running. If this situation applies to you, you can fix the issue simply by disabling the Office background task.
Step 1. Open the Run box, and then type taskschd.msc in it and hit Enter.
Step 2. In the Task Scheduler window, go to the Task Scheduler Library > Microsoft > Office path.
Step 3. Find the task named OfficeBackgroundTaskHandlerRegistration from the right pane, and then right-click it and select Disable.
Once completes, reboot your computer and check if the Command Prompt pops up and closes in Windows 11.
Fix 4. Run a Full Virus Scan
As mentioned above, the virus or malware infection is responsible for the Command Prompt pops up and closes on Windows 11. To exclude this factor, we highly recommend you perform a full scan of your system. For that:
Step 1. Press Win + I keys to open the Settings Windows, and then go to Privacy & security > Windows Security > Virus & threat protection.
Step 2. Click on Scan options to access more scan options, and then select Full scan and tap on Scan now to start the full virus scan. Then you need to wait a while until the scan completes. After that, you can restart your system and see if the “Command Prompt opens and closes Windows 11” issue is fixed.
Fix 5. Remove the Crypto-Mining AutorRun Registry key
It’s known that there is a particular security threat called SoundMixer that still can escape the vast majority of antivirus scans. To prevent Windows 11 from opening Command Prompt automatically or occurring some other issues, you can remove every registry key of the SoundMixer in Registry Editor.
Step 1. In the Run dialog box, type regedit and hit Ctrl + Shift + Enter to access the Registry Editor with admin right. Then click on Yes when you are prompted by the User Account Control access.
Step 2. In the Registry Editor window, click on Edit from the top ribbon menu and select Find.
Step 3. Type SOUNDMIXER in the Find What box, and make sure that the Keys, Values, and Data are all checked and click on Find Next.
Step 4. Wait for the Registry Editor to complete the search. Once you find that, right-click on AutoRun from the right pane and select Delete. Then click on Yes to confirm the delete.
Once removed, restart your computer and see if the Command Prompt pops up and closes in Windows 11.
Fix 6. Use the Task Scheduler
If all the above methods fail to fix the “Command Prompt opens and closes in Windows 11” issue, you can try using the Task Scheduler to investigate your tasks and processes that could be the potential causes. Here’s how:
Step 1. Open the Task Scheduler window like step 1 in Fix 3.
Step 2. Select Task Scheduler Library from the left-hand pane, and then check if any tasks are scheduled to run every 10 minutes from the right side or look at the Trigger section.
Step 3. If you find any suspicious tasks with a recurring trigger that opens up Command Prompt, right-click it and select Disabled. Here you should investigate the tasks mainly related to Office, Mozilla, and other third-party programs.