in src/ServiceMonitor/IISConfigUtil.cpp [202:247]
HRESULT IISConfigUtil::RunCommand(wstring& pstrCmd, BOOL fIgnoreError)
{
HRESULT hr = S_OK;
STARTUPINFO si = { sizeof(STARTUPINFO) };
DWORD dwStatus = 0;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFO);
si.dwFlags |= STARTF_USESTDHANDLES;
if (!CreateProcess(NULL,
(LPWSTR)pstrCmd.c_str(),
NULL,
NULL,
false,
0,
NULL,
NULL,
&si,
&pi))
{
hr = HRESULT_FROM_WIN32(GetLastError());
goto Finished;
}
//
// wait for at most 5 seconds to allow APPCMD finish
//
WaitForSingleObject(pi.hProcess, 5000);
if ((!GetExitCodeProcess(pi.hProcess, &dwStatus) || dwStatus != 0) && (!fIgnoreError))
{
//
// appcmd command failed
//
_tprintf(L"\nAPPCMD failed with error code %d\n", dwStatus);
hr = E_FAIL;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
Finished:
return hr;
}