When I open a program the command prompt window opens only

  • Thread starter Thread starter AASaunders
  • Start date Start date
  • Tags Tags
    Program Window
AI Thread Summary
A user encountered an issue after associating all executable files with cmd.exe, causing the command prompt to open for all applications, including Chrome. The problem arose from a misunderstanding of how to keep the command window open after executing a C program, which could have been resolved with the command 'system("pause")'. System restore was not an option for fixing the file association. To resolve the issue, a detailed method was provided involving the Windows Registry Editor (regedit), where the user could export the correct settings for executable files from another computer with the same Windows version. This process includes ensuring the default value for the .exe key is set to "exefile." Additionally, alternative suggestions were made to adjust file associations through Windows Explorer 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.
 
In my discussions elsewhere, I've noticed a lot of disagreement regarding AI. A question that comes up is, "Is AI hype?" Unfortunately, when this question is asked, the one asking, as far as I can tell, may mean one of three things which can lead to lots of confusion. I'll list them out now for clarity. 1. Can AI do everything a human can do and how close are we to that? 2. Are corporations and governments using the promise of AI to gain more power for themselves? 3. Are AI and transhumans...
Thread 'ChatGPT Examples, Good and Bad'
I've been experimenting with ChatGPT. Some results are good, some very very bad. I think examples can help expose the properties of this AI. Maybe you can post some of your favorite examples and tell us what they reveal about the properties of this AI. (I had problems with copy/paste of text and formatting, so I'm posting my examples as screen shots. That is a promising start. :smile: But then I provided values V=1, R1=1, R2=2, R3=3 and asked for the value of I. At first, it said...
Back
Top