MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / executeProgram

Function executeProgram

src/installer/gui/windows/bootstrap/main.cpp:65–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65static DWORD executeProgram(const wchar_t *cmd, const wchar_t *params, bool wait, bool asAdmin, LPDWORD exitCode)
66{
67 SHELLEXECUTEINFO ei;
68 memset(&ei, 0, sizeof(SHELLEXECUTEINFO));
69
70 ei.cbSize = sizeof(SHELLEXECUTEINFO);
71 ei.fMask = SEE_MASK_NOCLOSEPROCESS;
72 ei.lpFile = cmd;
73 ei.lpParameters = params;
74 ei.nShow = SW_RESTORE;
75 if (asAdmin) {
76 ei.lpVerb = L"runas";
77 }
78
79 BOOL result = ShellExecuteEx(&ei);
80
81 if (!result) {
82 debugMessage(_T("Windscribe Installer - ShellExecuteEx failed: %lu"), GetLastError());
83 return GetLastError();
84 }
85
86 wsl::Win32Handle processHandle(ei.hProcess);
87
88 if (wait && processHandle.isValid()) {
89 auto waitResult = processHandle.wait(INFINITE);
90 if (waitResult == WAIT_OBJECT_0 && exitCode != nullptr) {
91 result = ::GetExitCodeProcess(processHandle.getHandle(), exitCode);
92 if (!result) {
93 exitCode = 0;
94 debugMessage(_T("Windscribe Installer - GetExitCodeProcess failed: %lu"), GetLastError());
95 }
96 }
97 }
98
99 return NO_ERROR;
100}
101
102static void deleteFolder(const std::filesystem::path &folder)
103{

Callers 1

wWinMainFunction · 0.85

Calls 4

getHandleMethod · 0.80
debugMessageFunction · 0.70
isValidMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected