Using MS-DOS in C++

Re: Using MS-DOS in C++

Post by darkzhac on Sat Jan 17, 2009 10:56 pm
([msg=16484]see Re: Using MS-DOS in C++[/msg])

Hi... I am a new one here

the system() command is a very strong command, it can create havoc providing you know how to use it....

the argument to this command is what you type next to a prompt.....

you have to do lots of research here..... whatever is typed is executed in a prompt available in the comspec evironment variable in windows.... here is the main part, there are two things here one is cmd.exe and the other, both appear to be the same. but they are not..... they have different methods of access towards the processor and yes this function depends on two headers process.h and stdlib.h

so lets go to the coding.
void main()
system("cmd /c start notepad");

the "cmd/c" is and important one cause, comspec variable wouldn't allow everything to be executed.
---limitations.... the execution of set command is not accurate and the systemvaraible like "%userprofile%" cannot be used properly

so i have given you something.... you can continue to think more in you can put the above coding in an unending loop and insert more of "cmd /c start [your fav application]" and see what happens

and you can even edit registry with this

system("reg add [ur key]");

for more information type reg add /? in cmd.exe and learn more

editing registry can make serious damages to ur o/s
New User
New User
Posts: 1
Joined: Sat Jan 17, 2009 10:35 pm
Blog: View Blog (0)

Re: Using MS-DOS in C++

Post by nathandelane on Mon Jan 19, 2009 9:27 am
([msg=16581]see Re: Using MS-DOS in C++[/msg])

vladiftodi wrote:It is not Ms-DOS
unless you program it for MS-DOS of course
you do realize that this works under Linux freeBSD macOS and most OSes out there?
it just executes a system command system()
and cmd itself under windows it's just the terminal not ms-dos <.<

+1 to comperr. I know that "PAUSE" does not exist as a command in Linux, but here's a little extra proof: Linux/UNIX Pause Command.

On the other hand, running the following produces the crazy following output in a DOS prompt:

Code: Select all
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

U:\>help pause
Suspends processing of a batch program and displays the message
    Press any key to continue . . .
Me, Nathandelane, Highly influential to Hackerdom, Premature Optimization=
User avatar
Posts: 204
Joined: Thu Jun 26, 2008 11:26 am
Location: Utah
Blog: View Blog (0)

Re: Using MS-DOS in C++

Post by Orion001 on Tue Jan 20, 2009 8:58 pm
([msg=16689]see Re: Using MS-DOS in C++[/msg])

If your question hasn't been answered already, simply do this:
Code: Select all
#include <cstdlib>

int main ( void)
string mycommand = "ipconfig"; //You can use cin or scanf or whatever to put your input into here

This should work fine, tell me if it doesn't
Hope it helps!
New User
New User
Posts: 36
Joined: Tue Sep 09, 2008 5:44 am
Blog: View Blog (0)


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests