Answer» I want the code below so that when you press any key it will refresh the information. The code below runs alright in a batch script (when in MS-DOS code), but since changing it into a C++ program it doesn't work. It seems like the "Pause" system command in C++ closes the window when any key is pressed. So how can i make it so if will refresh all the information WITHOUT closing?
Code: [Select]#include <iostream> using namespace std; int main() { system(":start"); system("color 0a"); system("echo -- --"); system("echo -- (C) Copyright - MT3sh, 2007 (Version. 1.0.0.2) --"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo S-Y-S-T-E-M I-N-F-O-R-M-A-T-I-O-N:"); system("echo --------------------------------------------------------------------------"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo =========================================================================="); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo Time : %time%"); system("echo --------------------------------------------------------------------------"); system("echo Date : %date%"); system("echo --------------------------------------------------------------------------"); system("echo Computer Name : %computername%"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo Memory:\n"); system("mem"); system("echo -- --"); system("echo -- --"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo N-E-T-W-O-R-K I-N-F-O-R-M-A-T-I-O-N:"); system("echo --------------------------------------------------------------------------"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo =========================================================================="); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo ARP:\n"); system("arp -a"); system("echo -"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo IPConfig:\n"); system("ipconfig /all"); system("echo -"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo NETSTAT:\n"); system("echo -"); system("netstat -e -s"); system("echo -"); system("echo --------------------------------------------------------------------------"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo To Refresh All Information;"); system("pause"); system("cls"); system("goto start"); }You have not "converted your batch file to a C++ program". You have written a C++ program which shells out 53 separate times, once for each line. This will not work as you seem to think. What your program is doing is equivalent to a person typing 53 individual commands at the prompt, one after the other. The "pause" command will wait for a keypress, but the "goto start" command will fail, obviously, since you can't have labels at the command line, only in real batch files. You COULD have the whole batch file called e.g.
system("mybatch.bat");
You could redirect the output of the batch into a text file and process that file in a C++ program I suppose.
But why bother? You need to learn how to call Windows API functions.
Lol, Contrex I worked it out, and the way I wanted too. THANKS anyway.
Code: [Select]#include <iostream> using namespace std;
int main() { system("color 0a"); system("echo .........................................................................."); system("echo -- --"); system("echo -- (C) Copyright - MT3sh, 2007 (Version. 1.0.0.2) --"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo S-Y-S-T-E-M I-N-F-O-R-M-A-T-I-O-N:"); system("echo --------------------------------------------------------------------------"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo =========================================================================="); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo Time : %time%"); system("echo --------------------------------------------------------------------------"); system("echo Date : %date%"); system("echo --------------------------------------------------------------------------"); system("echo Computer Name : %computername%"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo Memory:\n"); system("mem"); system("echo -- --"); system("echo -- --"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo N-E-T-W-O-R-K I-N-F-O-R-M-A-T-I-O-N:"); system("echo --------------------------------------------------------------------------"); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo =========================================================================="); system("echo //////////////////////////////////////////////////////////////////////////"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo ARP:\n"); system("arp -a"); system("echo -"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo IPConfig:\n"); system("ipconfig /all"); system("echo -"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("echo Netstat:\n"); system("echo -"); system("netstat -e -s"); system("echo -"); system("echo --------------------------------------------------------------------------"); system("echo --------------------------------------------------------------------------"); system("echo -"); system("pause"); system("cls"); system("echo -- --"); system("echo To Refresh All Information;"); system("pause"); return main(); }
|