views:

134

answers:

2

I'm trying to port an NSIS installer to WiX. Every time the installer runs it sets a registry key to a new GUID value, so that when my app runs it can see if it's first run after an install. On first run the app sets another registry key to the GUID value from the installer. As long as the two keys match then I know the installer hasn't been run.

Here's the NSIS code:

#Write InstallGUID
Call CreateGUID
Pop $0
WriteRegStr HKLM "${REGKEY}" InstallGUID $0

and

Function CreateGUID
  System::Call 'ole32::CoCreateGuid(g .s)'
FunctionEnd

I've got a fairly complete WiX installer ready at this point, but I can't figure out how to replicate this functionality. Is there something in WiX to generate GUIDs at install time, or do I need to write a custom event? If I could avoid writing a little dll that would be best.

A: 

If you don't find a better solution you could put that code into an NSIS script by itself and make it a silent install so that you can silently run the NSIS script from the Wix+MSI installer.

I would be mindful to do appropriate error catching in the NSIS code and return/set error code to be returned back to Wix so that any registry related failures/errors can be communicated to the Wix installer.

AaronLS
A: 

It looks like this can be accomplished with a packaged dll, as shown in the SampleAskKey example in the WiX tutorial.

Not the most elegant, but it should get the job done.

tfinniga