Search This Blog

How to Execute Windows Commands in C

You may have used Windows commands like ipconfig, netstat, type, set, mkdir, cd etc in cmd (DOS Prompt or Command Prompt). You can execute these commands from a C program. This post will tell you how to execute Windows commands (cmd commands) from c program. To execute different Windows commands, you can use the system() function c language. The system() function is used to invoke command processor to execute a given command. The command which is to be executed is passed as argument to the function. An example c program with system() function is shown below.

#include<stdio.h>
void main()
{
system("ipconfig");
//use "help" command to get list of commands
}

No comments: