using the system() function...
here's a program i'm working on, at the moment it works the same as the cmd.exe, check to see how it calls the commands:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int main(void)
{
char comm[200];
char cwd[100];
char dir[200];
int i,j;
while(1)
{
getcwd(cwd,100);
printf("\n%s>",cwd);
gets(comm);
if(strlen(comm)>199)
free(comm);
if(strcmp(comm,"exit")==0||strcmp(comm,"quit")==0)
{
free(comm);
free(cwd);
return EXIT_SUCCESS;
}
if(comm[0]=='c'&&comm[1]=='d'&&comm[2]==' ')
{
j=3;
for(i=0;i<strlen(comm);i++)
{
dir[i]=comm[j];
j++;
}
chdir(dir);
}
else
{
system(comm);
}
}
return EXIT_SUCCESS;
}
so if you would like to execute the cmd you could use the following code:
Code:
#include <stdio.h>
int main(void)
{
char *command="cmd.exe";
system(command);
return 0;
}
hope this helps