diff --git a/programs/wcmd/wcmdmain.c b/programs/wcmd/wcmdmain.c index b3659a2c249..bea314ee3e6 100644 --- a/programs/wcmd/wcmdmain.c +++ b/programs/wcmd/wcmdmain.c @@ -67,6 +67,16 @@ HANDLE h; } } + /* If we do a "wcmd /c command", we don't want to allocate a new + * console since the command returns immediately. Rather, we use + * the surrently allocated input and output handles. This allows + * us to pipe to and read from the command interpreter. + */ + if (strstr(args, "/c") != NULL) { + WCMD_process_command (param); + return 0; + } + /* * Allocate a console and set it up. */ @@ -87,11 +97,6 @@ HANDLE h; WCMD_echo ("OFF"); } - if (strstr(args, "/c") != NULL) { - WCMD_process_command (param); - return 0; - } - if (strstr(args, "/k") != NULL) { WCMD_process_command (param); }