Skip to content

Commit

Permalink
Small update: Synchronize the return values of parent and child proce…
Browse files Browse the repository at this point in the history
…sses.

Signed-off-by: Fxzx mic <[email protected]>
  • Loading branch information
fxzxmic committed Jun 26, 2021
1 parent 1de0974 commit 2ed9f8d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions CMD_to_Bash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ int main(int argc, char* argv[]) {
}
ch += "\\\"\"\"";

DWORD dwExitCode;
wstring widstr;
widstr = wstring(ch.begin(), ch.end());
LPWSTR sConLin = (LPWSTR)widstr.c_str();
Expand All @@ -28,11 +29,12 @@ int main(int argc, char* argv[]) {
memset(&si, 0, sizeof(si));
memset(&pi, 0, sizeof(pi));

CreateProcess(NULL, sConLin, NULL, NULL, false, 0, NULL, NULL, &si, &pi);
CreateProcess(NULL, sConLin, NULL, NULL, true, 0, NULL, NULL, &si, &pi);

CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);

GetExitCodeProcess(pi.hProcess, &dwExitCode);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);

return 0;

return dwExitCode;
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# CMD_to_Bash
Forward CMD command to Bash
Relay CMD command to Bash
## How it Work
It gets its own program name and running parameters to splice into `bash.exe -c "<Program Name> <Running Parameters>"`, and create a `bash.exe` process with this command.
## How to Use
Expand Down

0 comments on commit 2ed9f8d

Please sign in to comment.