Hello List,
I'm using WiX for creating a setup with a keyfile with openSSL. The keyfile has to be placed in the ProgramFolderDir. After creating the key with the Custom Action, I push it in a Property called "LICENSE". Another function should write this file to the products shortname with ".key" extension. If I start the Installer from an administrator shell, all went fine. If I start it as user with administrator privileges, the Custom Action returns an error. -----snip Custom Action code /*************************************************************************** **/ bool writeToFile(const char *pcFileName, const char *pcData, DWORD szLen) { bool _bReturn = false; int _iFile = _open(pcFileName, _O_WRONLY | _O_CREAT, _S_IWRITE ); if(_iFile > 0) { if(_write(_iFile, pcData, szLen) == szLen) { _bReturn = true; } _close(_iFile); } return _bReturn; } /*************************************************************************** **/ UINT __stdcall writeKey(MSIHANDLE hInstall) { char _pcKeyPath[MAX_PATH]; DWORD _dKeyPathLen = MAX_PATH; char _pcLicence[1024]; DWORD _dLicenceLen = 1024; MsiGetPropertyA(hInstall, "INSTALLDIR", _pcKeyPath, &_dKeyPathLen); MsiGetPropertyA(hInstall, "LICENCE", _pcLicence, &_dLicenceLen); bool _bWriteSuccess = false; if(_dLicenceLen > 0) { if(_dKeyPathLen > 0) { string _sLicenceFile = _pcKeyPath; if(_sLicenceFile.size() > 0 && !(_sLicenceFile[_sLicenceFile.size()-1] == '/' || _sLicenceFile[_sLicenceFile.size()-1] == '\\')) { _sLicenceFile += "\\"; } _sLicenceFile += "mykey.key"; string _sLogMsg = "Writing key file to dir: "; _sLogMsg += _sLicenceFile; MsiSetPropertyA(hInstall, "LASTDLLACTION", _sLogMsg.c_str()); _bWriteSuccess = writeToFile(_sLicenceFile.c_str(), _pcLicence, _dLicenceLen); } } if(_bWriteSuccess) { MsiSetPropertyA(hInstall, "KEYWRITESUCCESS", "0"); } else { MsiSetPropertyA(hInstall, "KEYWRITESUCCESS", "-1"); MsiSetPropertyA(hInstall, "LASTDLLACTION", "Error writing key file"); } return ERROR_SUCCESS; } -----snip end of Custom Action code The dll is set by: <Binary Id="myInstaller" SourceFile="myInstaller.dll"/> The function is specified by: <CustomAction Id="writeKey" BinaryKey="myInstaller" DllEntry="writeKey" Execute="deferred" Impersonate="no"/> The install sequence calls the custom action before InstallFinalize <InstallExecuteSequence> <Custom Action="writeKey" Before="InstallFinalize">1</Custom> </InstallExecuteSequence> First I tried it after InstallFinalize and without the Execute and Impersonate attribute, but that doesn't work. In administrator shell, all action are done, so the code is fine, but something with rights, I guess. What I'm doing wrong ? How can I activate UAC or administrator privileges for running my function ? Does the dll needs a special initialization routine ? At linker section in Visual Studio I set the UACExecutionLevel="2" (administrator privileges), but nothing changed. I guess for dlls this is needless. Regards Michael ------------------------------------------------------------------------------ AppSumo Presents a FREE Video for the SourceForge Community by Eric Ries, the creator of the Lean Startup Methodology on "Lean Startup Secrets Revealed." This video shows you how to validate your ideas, optimize your ideas and identify your business strategy. http://p.sf.net/sfu/appsumosfdev2dev _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users