M
momo898
Guest
My installer project has a custom action which is creating a temp file in the temp folder by using GetTempFileName.
GetTempFileName created a empty temp file.
But after that it throws the following error when writing the temp file.
"Access to c:\Users\xxxx\AppData\Local\Temp\TBX4EDF.tmp was defined"
The issue is happening at only my client machines which are windows 10.
Administrator user or escalated privilege with "Run as Administrator" doesn't resolve the issue.
So I'm not sure if it's a really permission issue or a kind of MFC or c++ libraries.
Please refer to the below code.
I will appreciate that if you have any suggestion.
TCHAR szTempPath[MAX_PATH];
if (GetTempPath(MAX_PATH, szTempPath) == 0)
{
return ERROR_INSTALL_FAILURE;
}
TCHAR szTempFile[MAX_PATH];
if (GetTempFileName(szTempPath, _T("TBX"), 0, szTempFile) == 0)
{
return ERROR_INSTALL_FAILURE;
}
CString sConfigPath;
sConfigPath.Format(_T("%s%s.config"), sDestDir, sProductName);
CString sLine;
TRY
{
CStdioFile fConfig(sConfigPath, CFile::modeRead);
CStdioFile fTemp(szTempFile, CFile::modeWrite);
while (fConfig.ReadString(sLine) != FALSE)
{
CString sTrim(sLine);
sTrim.Trim();
if (sTrim.Compare(_T("xxxxxxx")) == 0)
{
fTemp.WriteString(_T("yyyyyy"));
}
else
{
sLine.Append(_T("\n"));
fTemp.WriteString(sLine);
}
}
}
CATCH_ALL(e)
{
e->ReportError(); // shows what's going wrong
return ERROR_INSTALL_FAILURE;
}
END_CATCH_ALL
Continue reading...
GetTempFileName created a empty temp file.
But after that it throws the following error when writing the temp file.
"Access to c:\Users\xxxx\AppData\Local\Temp\TBX4EDF.tmp was defined"
The issue is happening at only my client machines which are windows 10.
Administrator user or escalated privilege with "Run as Administrator" doesn't resolve the issue.
So I'm not sure if it's a really permission issue or a kind of MFC or c++ libraries.
Please refer to the below code.
I will appreciate that if you have any suggestion.
TCHAR szTempPath[MAX_PATH];
if (GetTempPath(MAX_PATH, szTempPath) == 0)
{
return ERROR_INSTALL_FAILURE;
}
TCHAR szTempFile[MAX_PATH];
if (GetTempFileName(szTempPath, _T("TBX"), 0, szTempFile) == 0)
{
return ERROR_INSTALL_FAILURE;
}
CString sConfigPath;
sConfigPath.Format(_T("%s%s.config"), sDestDir, sProductName);
CString sLine;
TRY
{
CStdioFile fConfig(sConfigPath, CFile::modeRead);
CStdioFile fTemp(szTempFile, CFile::modeWrite);
while (fConfig.ReadString(sLine) != FALSE)
{
CString sTrim(sLine);
sTrim.Trim();
if (sTrim.Compare(_T("xxxxxxx")) == 0)
{
fTemp.WriteString(_T("yyyyyy"));
}
else
{
sLine.Append(_T("\n"));
fTemp.WriteString(sLine);
}
}
}
CATCH_ALL(e)
{
e->ReportError(); // shows what's going wrong
return ERROR_INSTALL_FAILURE;
}
END_CATCH_ALL
Continue reading...