Reputation: 61
I tried Start cmd to open new cmd prompt but i am not able to give command line arguments in new cmd ..
I tried with following
system("start cmd") >> "system("C:\\Windows\\System32\\ipconfig");
not working
system(start system("C:\\Windows\\System32\\ipconfig"));
not working
Upvotes: 2
Views: 227
Reputation: 148910
As said by Dipak D Desai, you can simply use
system("cmd /c start C:\\Windows\\System32\\ipconfig");
But if you do that in a non console application, here is what will happen :
ipconfig
in that windowipconfig
has ended.If you want the window to stay open after the end of the command, you can use :
system("cmd /c start cmd /k C:\\Windows\\System32\\ipconfig");
The first cmd /c
allows to pass the command start
that is an internal command. The second cmd /c
(or cmd /k
) starts a new shell (cmd.exe
) but ask it not to close after executing first command, but instead to open a command loop.
In fact, the first cmd /c
is not necessary, since it is implied by the system
call. So it should be omitted from the command even if is is harmless (thanks to @eryksun for noticing)
Upvotes: 2
Reputation: 877
Launch a separate CMD Windows, you need to call cmd.exe:
system("cmd.exe /c C:\\Windows\\System32\\ipconfig");
Upvotes: 1