Home › Forums › Archives › Computer Support › Computer Support Discussion › Microsoft XP closes windows as soon as I open them
- This topic has 4 replies, 3 voices, and was last updated 22 years, 5 months ago by
ShadowSlayer469.
-
AuthorPosts
-
April 25, 2004 at 1:04 pm #10281
ShadowSlayer469
MemberOkay, this is really anoying, I have Windows XP and whenever I try to open any .bat file, or any .exe file that I have compiled on my own the DOS window simply flashes and than dissapears. Can somone please tell me what is going on? This really annoys me.
[Moved from: Random Ramblings]
[Sorry about that its been a long time since I’ve been here and I didnt see it.]April 25, 2004 at 2:37 pm #80662Charles
MemberI am not sure how to get them to stay open either when you run them from Explorer. However, if you navigate to their location in the Command Prompt and execute them that way they do stay open.
Wouldn’t this be in the new Computer Support?
April 27, 2004 at 12:45 pm #80664ShadowSlayer469
MemberWell, thanks and I found out how what the problem is, at least for my .exe files, I just inserted “system(“pause”)” when I was writing the code, but I still dont know why the .bat files are closing. Thanks anyway
April 27, 2004 at 1:52 pm #80661DJHyperbyte
MemberQuote:quote:Originally posted by ShadowSlayer469Well, thanks and I found out how what the problem is, at least for my .exe files, I just inserted “system(“pause”)” when I was writing the code, but I still dont know why the .bat files are closing. Thanks anyway
Ah, C++’ing are we? 😉
Newer Windows versions automatically close MS-DOS programs as soon as they’re finished executing. So as soon as your C++ program has executed the last command Windows closes it. The same counts with your .BAT files.
Putting “pause” on the end of the BAT file will make Windows wait ’till the user presses any key. You could as well call the “pause” command from C++, like you did with “system(“pause”)“, however, it might suit you more to write some C++ code that accomplishes this.
// Input/output
#include
// Standard namespace
using namespace std;// Program starts here
void main()
{
// Wait for the user to press ENTER.
cout << "Press ENTER to quit.";
cin.ignore();
cin.get();
}[/CODE][/list][CODE]// Input/output
#include
// Standard namespace
using namespace std;// Program starts here
void main()
{
// Wait for the user to press ENTER.
cout << "Press ENTER to quit.";
cin.ignore();
cin.get();
}[/CODE]April 28, 2004 at 9:56 pm #80663ShadowSlayer469
MemberQuote:quote:Originally posted by DJHyperbyteQuote:quote:Originally posted by ShadowSlayer469Well, thanks and I found out how what the problem is, at least for my .exe files, I just inserted “system(“pause”)” when I was writing the code, but I still dont know why the .bat files are closing. Thanks anyway
Ah, C++’ing are we? 😉
Newer Windows versions automatically close MS-DOS programs as soon as they’re finished executing. So as soon as your C++ program has executed the last command Windows closes it. The same counts with your .BAT files.
Putting “pause” on the end of the BAT file will make Windows wait ’till the user presses any key. You could as well call the “pause” command from C++, like you did with “system(“pause”)“, however, it might suit you more to write some C++ code that accomplishes this.
// Input/output
#include
// Standard namespace
using namespace std;// Program starts here
void main()
{
// Wait for the user to press ENTER.
cout << "Press ENTER to quit.";
cin.ignore();
cin.get();
}[/CODE][/list]
[/quote]Thanks a whole lot ^^ im new to C++ and this has really helped[CODE]// Input/output
#include
// Standard namespace
using namespace std;// Program starts here
void main()
{
// Wait for the user to press ENTER.
cout << "Press ENTER to quit.";
cin.ignore();
cin.get();
}[/CODE]Thanks a whole lot ^^ im new to C++ and this has really helped
-
AuthorPosts
- You must be logged in to reply to this topic.