Skip to content

Commit

Permalink
Merge pull request #55316 from Chaosus/win32_restore_console_window
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Nov 25, 2021
2 parents a5f878d + 675111e commit 2681d93
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions platform/windows/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,12 @@ Error OS_Windows::execute(const String &p_path, const List<String> &p_arguments,
ZeroMemory(&pi.pi, sizeof(pi.pi));
LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si;

int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi);
DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS;
#ifndef DEBUG_ENABLED
dwCreationFlags |= CREATE_NO_WINDOW;
#endif

int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, dwCreationFlags, nullptr, nullptr, si_w, &pi.pi);
ERR_FAIL_COND_V_MSG(ret == 0, ERR_CANT_FORK, "Could not create child process: " + command);

WaitForSingleObject(pi.pi.hProcess, INFINITE);
Expand Down Expand Up @@ -475,7 +480,12 @@ Error OS_Windows::create_process(const String &p_path, const List<String> &p_arg
ZeroMemory(&pi.pi, sizeof(pi.pi));
LPSTARTUPINFOW si_w = (LPSTARTUPINFOW)&pi.si;

int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, NORMAL_PRIORITY_CLASS | CREATE_NO_WINDOW, nullptr, nullptr, si_w, &pi.pi);
DWORD dwCreationFlags = NORMAL_PRIORITY_CLASS;
#ifndef DEBUG_ENABLED
dwCreationFlags |= CREATE_NO_WINDOW;
#endif

int ret = CreateProcessW(nullptr, (LPWSTR)(command.utf16().ptrw()), nullptr, nullptr, false, dwCreationFlags, nullptr, nullptr, si_w, &pi.pi);
ERR_FAIL_COND_V_MSG(ret == 0, ERR_CANT_FORK, "Could not create child process: " + command);

ProcessID pid = pi.pi.dwProcessId;
Expand Down

0 comments on commit 2681d93

Please sign in to comment.