Added support for environment variable SQUIRREL_TEMP to Setup.exe

Allows to control where Setup.exe will extract and execute the package
This commit is contained in:
Lennart Jansson
2016-10-05 12:57:03 +02:00
parent 6722c66f77
commit c3def2a7c3

View File

@@ -137,6 +137,11 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine, bool useFallback
wchar_t logFile[MAX_PATH];
std::vector<CString> to_delete;
wchar_t *envSquirrelTemp = _wgetenv(L"SQUIRREL_TEMP");
if (envSquirrelTemp) {
_swprintf_c(targetDir, _countof(targetDir), L"%s", envSquirrelTemp);
}
else {
if (!useFallbackDir) {
SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, targetDir);
} else {
@@ -161,6 +166,7 @@ int CUpdateRunner::ExtractUpdaterAndRun(wchar_t* lpCommandLine, bool useFallback
}
wcscat_s(targetDir, _countof(targetDir), L"\\SquirrelTemp");
}
if (!CreateDirectory(targetDir, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) {
wchar_t err[4096];