Hans Leidekker (@hans) commented about programs/wmic/main.c:
- if(argc == 1)
- {
STARTUPINFOW si = {0};
PROCESS_INFORMATION pi = {0};
output_error( STRING_INTERACTIVE );
while (fgetws(cmd, sizeof(cmd), stdin) != NULL)
{
WCHAR wmic[MAX_STRING] = L"wmic.exe ", stripped[MAX_STRING], *ptr, *token;
cmd[wcslen(cmd)-1] = 0; /* remove trailing '\n' */
stripped[0] = 0; /* FIXME: remove extra spaces from comma seperated list, by breaking it up and rebuild it, is there a better way? */
token = wcstok( cmd, L",", &ptr );
I see no need to create a new process. Commands should be handled the same as when passed on the command line, so you need to split the buffer into class, verb and properties. The existing code already handles spaces in the property list.