[PATCH v3 0/1] MR5402: wmic.exe: Support interactive mode and piped commands
See also https://bugs.winehq.org/show_bug.cgi?id=56361 This patch makes piped commands work like for example "echo os get version|wmic" or "type file.txt | wmic" where file.txt contains some commands. (probably used by program in aforementioned bugreport) Also support interactive mode (wine wmic.exe) Marked for now as draft. -- v3: wmic.exe: Support interactive mode and piped commands. https://gitlab.winehq.org/wine/wine/-/merge_requests/5402
From: Louis Lenders <xerox.xerox2000x(a)gmail.com> See also https://bugs.winehq.org/show_bug.cgi?id=56361 This patch makes piped commands work like for example "echo os get version|wmic" or "type file.txt | wmic" where file.txt contains some commands. (probably used by program in aforementioned bugreport) Also support interactive mode (wine wmic.exe) --- programs/wmic/main.c | 35 +++++++++++++++++++++++++++++++++++ programs/wmic/wmic.h | 1 + programs/wmic/wmic.rc | 1 + 3 files changed, 37 insertions(+) diff --git a/programs/wmic/main.c b/programs/wmic/main.c index 936fe45139d..da84bf04097 100644 --- a/programs/wmic/main.c +++ b/programs/wmic/main.c @@ -34,6 +34,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(wmic); +#define MAX_STRING 4096 static const struct { const WCHAR *alias; @@ -337,9 +338,43 @@ int __cdecl wmain(int argc, WCHAR *argv[]) { const WCHAR *class, *value; int i; + WCHAR cmd[MAX_STRING]; setlocale( LC_ALL, "" ); + if (argc == 1) + { + STARTUPINFOW si = {0}; + PROCESS_INFORMATION pi = {0}; + + fputws( L"wbem:root\\cli>", stdout ); + + while (fgetws(cmd, sizeof(cmd), stdin) != NULL) + { + WCHAR wmic[MAX_STRING] = L"wmic.exe "; + + cmd[wcslen(cmd)-1] = 0; /* remove trailing '\n' */ + + WINE_FIXME("command: %s\n", debugstr_w(cmd)); + if (!wcsicmp( strip_spaces(cmd), L"exit" ) || !wcsicmp( strip_spaces(cmd), L"quit" )) + return 0; + + if (!cmd[0]) + output_error( STRING_USAGE ); + else + { + CreateProcessW( 0, wcscat( wmic, cmd ), 0, 0, 0, 0, 0, 0, &si, &pi ); + WaitForSingleObject( pi.hProcess, INFINITE ); + CloseHandle( pi.hProcess ); + CloseHandle( pi.hThread ); + + output_newline(); + } + fputws( L"wbem:root\\cli>", stdout ); + } + return 0; + } + for (i = 1; i < argc && argv[i][0] == '/'; i++) WINE_FIXME( "command line switch %s not supported\n", debugstr_w(argv[i]) ); diff --git a/programs/wmic/wmic.h b/programs/wmic/wmic.h index 27272706af5..bb095169c8b 100644 --- a/programs/wmic/wmic.h +++ b/programs/wmic/wmic.h @@ -22,3 +22,4 @@ #define STRING_ALIAS_NOT_FOUND 102 #define STRING_INVALID_QUERY 103 #define STRING_INVALID_PATH 104 +#define STRING_INTERACTIVE 105 diff --git a/programs/wmic/wmic.rc b/programs/wmic/wmic.rc index 0789ef34631..797fe7dbe08 100644 --- a/programs/wmic/wmic.rc +++ b/programs/wmic/wmic.rc @@ -28,4 +28,5 @@ STRINGTABLE STRING_ALIAS_NOT_FOUND, "Error: Alias not found\n" STRING_INVALID_QUERY, "Error: Invalid query\n" STRING_INVALID_PATH, "Error: Invalid syntax for PATH\n" + STRING_USAGE, "Supply a command\n" } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5402
Hi, It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated. The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=144406 Your paranoid android. === debian11 (build log) === ../wine/programs/wmic/main.c:363:31: error: ���STRING_USAGE��� undeclared (first use in this function) Task: The win32 Wine build failed === debian11b (build log) === ../wine/programs/wmic/main.c:363:31: error: ���STRING_USAGE��� undeclared (first use in this function) Task: The wow64 Wine build failed
participants (3)
-
Louis Lenders -
Louis Lenders (@xe) -
Marvin