Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: {Programming in C++} Command Prompt

16 Apr 2012   #1
Trinty

Windows 7 Ultimate x64 - Service Pack 1
 
 
{Programming in C++} Command Prompt

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 :


Quote:
#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 System SpecsSystem Spec
.

16 Apr 2012   #2
fseal

Windows 7 x64 Ultimate
 
 

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 System SpecsSystem Spec
16 Apr 2012   #3
Trinty

Windows 7 Ultimate x64 - Service Pack 1
 
 

Quote   Quote: Originally Posted by fseal View Post
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 System SpecsSystem Spec
.


Reply

 {Programming in C++} Command Prompt




Thread Tools





Similar help and support threads
Thread Forum
How to fix MBR through command prompt?
Question: What commands could I run in the command prompt during the system recovery? I try & run say "fixmbr" but it doesn't work. Say if I want to write a new master boot record how would I do that?
General Discussion
SSH command prompt
Is there any way I can use ssh or something similar to enter command line prompts from my Mac terminal, similar to SSH but windows commands? (From mac to a windows 7 desktop)
Performance & Maintenance
Run administrative command prompt from command prompt
Ok So I got myself into a unique bind here. I was trying to install some custom system files (for a theme) and I did it wrong and now I cant open explorer.exe . I dont want to goto a backup because this is a easy fix. (in my view). So I need to know how to run command prompt with administrative...
General Discussion
Command Prompt
Ok so every time I try to open the command prompt using an external source (batch file, small c++ program i made to say Hi to me through the command prompt) it instantly closes. Does anyone have any idea why this is happening and if so how can I fix it? Thanks, Wave
General Discussion
command prompt bug ?
Hi, I just tryed to use cmd as usual but it seems that I can't explore an other HDD than C: It bugs me I don't understand why i'm the only user on my computer and I am admin on it I at home so it should work but when I type "cd d:" I get that : ...
General Discussion
Command Prompt command <ipconfig> not working
when I open up my command prompt and type 'ipconfig' without the ' and press enter it returns the line: 'ipconfig' is nto recognized as an internal or external command, operable program, or batch file I am trying to find out the information I need in order to set up a static IP Address for port...
Network & Sharing

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 20:55.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App