Solved {Programming in C++} Command Prompt

Trinty

New member
Power User
Local time
8:40 PM
Messages
144
Hello SF members.

Today I started with creating one software like Microsoft Command Prompt.
There will be classic Command Prompt and some shortcuts, like ipconfig, chkdsk and etc.

But I need help with first option : Command Prompt Classic edition.
I want to that option be like normal CMD. Enter command and press enter to execute.
I need this code for command. To enter command and press enter to execute.

I know for command system("command"); , where is command for ex. format c:\.
I typed in code system(command); where command is "string command;" and I have code , "cin >> command;" where I need to enter this command. But that dont work for me. I always good error and that dont work.

I need one working code for this. Can anyone please send it ?

Note : I dont know where to post it. So if subforum is wrong please move it.
Code for my current program :


#include <iostream>
#include <conio.h>
#include <string>
using namespace std;


void main(){

string selection;


cout << "Welcome to Command Prompt Extended - v1Beta r0001." << endl;
cout << "Created by Trinty. All rights reserved" << endl;
cout << endl;
cout << endl;
cout << "Enter number for function and press enter !" << endl;
cout << endl;
cout << "1. Enter Command Prompt" << endl;
cout << "2. Shutdown computer (60 sec)" << endl;
cout << "3. Run Disk Check " << endl;
cout << "4. Run ipconfig" << endl;
cout << "5. UNDER CONSTRUCTION !" << endl;
cout << "6. UNDER CONSTRUCTION !" << endl;
cout << "7. Unlock Windows CMD. USE AT YOUR OWN RISK !" << endl;
cout << "8. Add Administrator privileges" << endl;
cout << "9. About" << endl;
cout << "10. Exit" << endl;
cout << endl;
cin >> selection;
cout << endl;

if(selection == "1"){
string command;
cout << "Welcome to Command Prompt Classic edition." << endl;
cout << "Enter command and press enter to execute command" << endl;
cout << endl;
cin >> command;
cout << endl;
_getch();
}

}

Thanks in advance.
Please answer soon.
Trinty :)
 

My Computer

Computer Manufacturer/Model Number
Trinty Self Build 2011
OS
Windows 7 Ultimate x64 - Service Pack 1
CPU
Intel(R) Pentium(R) CPU G620 @ 2.60GHz
Motherboard
ASUSTeK Computer INC. P8H61-M LX2
Memory
Transcend Informations - 2*2048GB DDR3 @ 1066MHz
Graphics Card(s)
ATI Radeon HD 5670 - 1024MB DDR5 - Driver : 19.04.2011
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
SAMSUNG SyncMaster 2220LM 22"
Screen Resolution
1680x1050
Hard Drives
SAMSUNG HD503HI ATA Device - 500GB
PSU
Don't know for now !
Case
Case MSI
Cooling
Stock
Keyboard
MS Industrial 2.4GHz Wirelees Keyboard
Mouse
MS Industrial 2.4GHz Wirelees Optical Mouse
Internet Speed
Download speed : 6,5Mbps / Upload speed : 1Mpbs
Other Info
BIOS version : BIOS Date: 02/05/10 19:13:52 Ver: 08.00.10
Prime95 (4h) : max. 65°C
DirectX 11 version.
Logitech G13 Advanced Gaming Keyboard.
Is this for Windows or Linux?

"system()" is a Linux function. On Windows you would use either ShellExecute or more likely CreateProcess with cmd.exe and pass your shell command as the command line for it...
 

My Computer

Computer Manufacturer/Model Number
Scratch built
OS
Windows 7 x64 Ultimate
CPU
i7 960
Motherboard
Asus P6X58D
Memory
12 Gig Corsair Dominator
Graphics Card(s)
Nvidia 480
Sound Card
Maudio Delta 44 + breakout box
Monitor(s) Displays
Dell UltraSharp U2410 24in and Samsung 21 dual monitors
Screen Resolution
1920x1200 and 1280x1024
Hard Drives
Primary: Intel X-25M G2 160G SSD
Secondary: Segate baracuda 1.0 TB
HDs in AHCI mode.
PSU
Corasair TX850
Case
Cooler Master HAF
Cooling
Corsair H50
Keyboard
Logitech G15 + N52 game pad
Mouse
Logitech MX518
Internet Speed
15kbs down 4.5kbps up
Other Info
WEI 7.6
CPU & RAM 7.6
Graphics 7.9
Hard disk 7.7
Is this for Windows or Linux?

"system()" is a Linux function. On Windows you would use either ShellExecute or more likely CreateProcess with cmd.exe and pass your shell command as the command line for it...

That is for Windows.
Can you give code for Windows ?

Thanks in advance.
Trinty.
 

My Computer

Computer Manufacturer/Model Number
Trinty Self Build 2011
OS
Windows 7 Ultimate x64 - Service Pack 1
CPU
Intel(R) Pentium(R) CPU G620 @ 2.60GHz
Motherboard
ASUSTeK Computer INC. P8H61-M LX2
Memory
Transcend Informations - 2*2048GB DDR3 @ 1066MHz
Graphics Card(s)
ATI Radeon HD 5670 - 1024MB DDR5 - Driver : 19.04.2011
Sound Card
AMD High Definition Audio Device
Monitor(s) Displays
SAMSUNG SyncMaster 2220LM 22"
Screen Resolution
1680x1050
Hard Drives
SAMSUNG HD503HI ATA Device - 500GB
PSU
Don't know for now !
Case
Case MSI
Cooling
Stock
Keyboard
MS Industrial 2.4GHz Wirelees Keyboard
Mouse
MS Industrial 2.4GHz Wirelees Optical Mouse
Internet Speed
Download speed : 6,5Mbps / Upload speed : 1Mpbs
Other Info
BIOS version : BIOS Date: 02/05/10 19:13:52 Ver: 08.00.10
Prime95 (4h) : max. 65°C
DirectX 11 version.
Logitech G13 Advanced Gaming Keyboard.
Back
Top