in src/ServiceMonitor/IISConfigUtil.cpp [146:199]
HRESULT IISConfigUtil::BuildAppCmdCommand(const vector<pair<wstring, wstring>>& vecSet, vector<pair<wstring, wstring>>::iterator& envVecIter, WCHAR* pstrAppPoolName, wstring& pStrCmd, APPCMD_CMD_TYPE appCmdType)
{
HRESULT hr = S_OK;
_ASSERT(pstrAppPoolName != NULL);
pStrCmd.append(m_pstrSysDirPath);
pStrCmd.append(L"\\inetsrv\\appcmd.exe set config -section:system.applicationHost/applicationPools ");
for (; envVecIter != vecSet.end(); envVecIter++)
{
wstring strEnvName = envVecIter->first;
wstring strEnvValue = envVecIter->second;
//
// Handle values that have single and double quotes
//
Replace(strEnvName, L"'", L"''");
Replace(strEnvName, L"\"", L"\"\"\"");
Replace(strEnvValue, L"'", L"''");
Replace(strEnvValue, L"\"", L"\"\"\"");
if ((pStrCmd.length() + strEnvName.length() + strEnvValue.length()) > APPCMD_MAX_SIZE)
{
//
// caller need to call again
//
hr = ERROR_MORE_DATA;
break;
}
if (appCmdType == APPCMD_ADD)
{
pStrCmd.append(L"/+\"[name='");
}
else
{
pStrCmd.append(L"/-\"[name='");
}
pStrCmd.append(pstrAppPoolName);
pStrCmd.append(L"'].environmentVariables.[name='");
pStrCmd.append(strEnvName);
if (appCmdType == APPCMD_ADD)
{
pStrCmd.append(L"',value='");
pStrCmd.append(strEnvValue);
}
pStrCmd.append(L"']\" ");
}
pStrCmd.append(L" /commit:apphost");
return hr;
}