When I open a program the command prompt window opens only

  • Thread starter Thread starter AASaunders
  • Start date Start date
  • Tags Tags
    Program Window
Click For Summary

Discussion Overview

The discussion revolves around a user experiencing issues with their Windows operating system after associating all executable files with the command prompt (cmd.exe). Participants explore potential solutions to revert this change and restore normal functionality for opening applications.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant describes their mistake of associating .exe files with cmd.exe, leading to unintended behavior when launching applications.
  • Another participant suggests using 'system("pause")' in C programs to prevent the command prompt from closing immediately after execution.
  • A participant questions the Windows version of the user experiencing the issue, implying that the solution may vary based on the operating system.
  • Several steps are proposed for restoring the default .exe file association using the Windows registry, including exporting registry keys and ensuring the correct default value is set.
  • One participant suggests an alternative approach of changing default behaviors through Windows Explorer settings instead of using the registry.

Areas of Agreement / Disagreement

Participants provide various methods to address the issue, but there is no consensus on the best approach. Some suggest registry edits while others propose using Windows Explorer settings, indicating multiple competing views on how to resolve the problem.

Contextual Notes

Participants express uncertainty about the effectiveness of the proposed solutions, particularly regarding the specific Windows version and the potential risks of editing the registry.

Who May Find This Useful

This discussion may be useful for individuals encountering similar issues with file associations in Windows, particularly those learning programming or troubleshooting system settings.

AASaunders
Messages
4
Reaction score
0
Hi all, I have just started to teach myself C and yesterday I did something awfully stupid.

I wrote a source file, exexuted it and I didn't know why the cmd window only briefly appeared, I now know that the line 'system("pause") would of fixed this. Regardless, I went to my .exe created by my compiler and set it to open with cmd.exe. Of course this associated all programs with cmd, so when I run Chrome for example the command window opens and that's it, I know I could just type in the filepath to open it but I would just like to revert it to how it was.

Also, system restore doesn't work so I can't take that route.

Thanks for any help.
 
Computer science news on Phys.org
AASaunders said:
Hi all, I have just started to teach myself C and yesterday I did something awfully stupid.

Murphy's law rules.

murphys-law.jpg


I wrote a source file, exexuted it and I didn't know why the cmd window only briefly appeared,

The Command Prompt always pops up for non-windows applications, and if your program just execute and end, you will only see a brief appearance.

I now know that the line 'system("pause") would of fixed this. Regardless, I went to my .exe created by my compiler and set it to open with cmd.exe.

Gosh, this shouldn’t be possible... what Windows version do you have?

Of course this associated all programs with cmd, so when I run Chrome for example the command window opens and that's it, I know I could just type in the filepath to open it but I would just like to revert it to how it was.

I can understand this. :smile:

Also, system restore doesn't work so I can't take that route.

Thanks for any help.

1. Make a backup of your entire system + data.

2. Look for a computer that has exactly the same Windows version as yours (maybe your laptop, friend, etc).

3. Make sure this computer has a recent backup for the entire system + data.

4. Go to the Start Menu and click on Run... and type regedit and press [Enter].

5. Press [Crtl+F] and type exefile and select Keys and Match whole string only and press [Enter].

6. Make sure it says Computer\HKEY_CLASSES_ROOT\exefile in the Status Bar.

7. Right-click on exefile in the tree in the right panel and select Export.

8. Save the file as RestoreExeFile.reg (or any suitable name) to the Desktop (or any other place where you can find it easily).

9. Copy the file to your computer and double-click on RestoreExeFile.reg and now your system should be restored.

10. Reboot your computer and remember to be careful out there! :wink:



Edit: I missed one thing.

11. On your computer start regedit as in 4.

12. Go to key HKEY_CLASSES_ROOT\.exe which is fairly easy to find (double-click HKEY_CLASSES_ROOT and scroll down).

13. Click on key .exe and make sure the value of (Default) is exefile.

14. If not, double-click on (Default) to change it.


Done!
 
Last edited:
Explained very well, thanks for the help!
 
No worries. :wink:

P.S: You could try to go directly from paragraph 1 to 11. If you’re lucky this will work.
 
It might be easier just to go into the Windows Explorer settings and dig down and change the default behavior for different file extensions.
 

Similar threads

Replies
14
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 5 ·
Replies
5
Views
5K
  • · Replies 8 ·
Replies
8
Views
7K
  • · Replies 7 ·
Replies
7
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K
Replies
5
Views
8K
  • · Replies 1 ·
Replies
1
Views
2K