I have a problem with WiX and C++ custom actions DLL: In my custom action I create a file and when I debug it, I got an access denied.
WiX file:
<CustomAction Id="ChangeConfig"
BinaryKey="PcmConfig"
DllEntry="ModifyConfigFile"
Execute="immediate"
Return="check"
HideTarget="no" />
<InstallExecuteSequence>
<Custom Action="ChangeConfig" Before="InstallFinalize" />
</InstallExecuteSequence>
Custom Action method:
HANDLE hFile = CreateFile(L"c:\Temp.txt", // name of the write
GENERIC_WRITE,
0,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
I saw some people suggested to change to run as deferred and Impersonate attribute set to "no", it seems it didn't call the custom action function at all.
Anyone a idea? Thanks in advance!
Have you tried adding a extra slash to make it "C:\\\\Temp.txt" or did the stackoverflow formatting remove it from your pasted code? If that doesn't work, try creating a C:\\Temp\\ folder as I've seen some OS's (or group policies) protect that root folder from having new files created (but allowed files to be copied into it), while sub-folders were allowed to create a new file.
HANDLE hFile = CreateFile(L"c:\\Temp.txt", // name of the write
GENERIC_WRITE,
0,
NULL,
CREATE_NEW,
FILE_ATTRIBUTE_NORMAL,
NULL);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.