C++ ShellExecute()

Hi all,

I've written a C++ code to call cmd.exe from within this code as shown below:

ShellExecute( NULL, "open", "C:\\WINDOWS\\system32\\cmd.exe",
"ipconfig", "C:\\", SW_SHOWNORMAL);

It calls the cmd.exe and the command window comes up on the screen,but it does not pass the "ipconfig" to it so no action is executed.

Does anyone know how to pass the "ipconfig" to the command window and execute it (so current IP configuration appears in the cmd window)?

Any help will be appreciated.
Thanx.

Mux.
Hi, i would suggest using system instead of shellExecute
 
	system("ipconfig");       


but you can open in command promt "ipconfig" using shellExecute
1
2
3
4
5
6
7
8
	ShellExecute(
		NULL,
		_T("open"),                     
		_T("cmd"),
		_T(" /C ipconfig"), // params                            
		_T(" C:\ "), 
		SW_SHOW);
Last edited on
Topic archived. No new replies allowed.