When I open a program the command prompt window opens only

In summary: Chrome opens automatically with cmd.exe when I run it from the source file. I want to revert it to how it was before.I can understand this. :smile: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_CLASS
  • #1
AASaunders
4
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
  • #2
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:
  • #3
Explained very well, thanks for the help!
 
  • #4
No worries. :wink:

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

What could be causing the command prompt window to open when I open a program?

There are a few potential reasons why this could be happening. One possibility is that the program you are opening is a command-line program and therefore requires the use of the command prompt. Another possibility is that the program is running a command prompt script or batch file as part of its startup process. It could also be caused by a corrupted program file or an issue with your computer's registry.

How can I prevent the command prompt window from opening when I open a program?

If the program you are opening is a command-line program, there is no way to prevent the command prompt window from opening. However, if the window is opening due to a script or batch file, you may be able to edit the file to prevent it from launching the command prompt. You could also try running the program as an administrator to see if that prevents the command prompt window from appearing.

Is it possible to change the default program for opening files?

Yes, it is possible to change the default program for opening files. This can usually be done by right-clicking on the file, selecting "Open with," and then choosing the desired program. You can also go into your computer's settings and change the default program for a specific file type.

Why does the command prompt window close immediately after opening?

This could be happening for a few reasons. One possibility is that the program you are opening is meant to quickly run a command and then close the command prompt window. Another possibility is that there is an issue with the program or script itself, causing it to close unexpectedly. You may also accidentally be pressing a key that closes the window, such as the "X" button on your keyboard.

Can I use the command prompt to open programs?

Yes, it is possible to use the command prompt to open programs. You can do this by typing the name of the program and its location in the command prompt, or by using the "start" command followed by the program's name. However, this may not work for all programs, especially if they require a graphical interface to run. It is also important to ensure that the program's file path is included in your computer's PATH environment variable.

Similar threads

  • Programming and Computer Science
Replies
14
Views
2K
  • Computing and Technology
Replies
18
Views
1K
  • Computing and Technology
Replies
2
Views
3K
  • Programming and Computer Science
Replies
12
Views
3K
  • Programming and Computer Science
Replies
8
Views
6K
  • STEM Career Guidance
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
5K
  • Programming and Computer Science
Replies
7
Views
5K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
5
Views
7K
Back
Top