Discussion:
[WiX-users] Create New Guid in Installer
Steve Bush
2008-02-18 16:07:12 UTC
Permalink
Does anyone know of an easy way in WIX to automatically create a GUID on install? I want to create a GUID that represents the user and place it in the registry. Here's an example:

<RegistryValue Root="HKCU" Key="Software\<omitted>" Name="UserId" Value="<newGuid>" Type="string" Action="write" />
k***@dsl.pipex.com
2008-02-18 22:18:53 UTC
Permalink
I'm new to wix and msi but it looks like you'll need to use a custom action, you could call into a dll or write a
vbscript (it looks like using scripts in custom actions may be frowned upon), anyway you can set a property to a new
guid and then reference that, the simplest example would be with a vbscript custom action.

<Product ...>

...

<Binary Id="VbScriptKit" SourceFile="VbScriptKit.vbs"/>
<CustomAction Id="CreateUserGuid" Return="check" BinaryKey="VbScriptKit" VBScriptCall="CreateUserGuid"/>

<InstallExecuteSequence>
<Custom Action="CreateUserGuid" After="CostFinalize"/>
</InstallExecuteSequence>

...

</Product>

---

VbScriptKit.vbs (make sure this is ASCII)

Option Explicit

Function CreateUserGuid()
Session.Property("USERGUID") = Mid(CreateObject("Scriptlet.TypeLib").GUID, 2,36)
CreateUserGuid = 1
End Function

---

you should make the function more robust but it's just a sample.

Here's the relevant snippet of the install log:

Action ended 21:49:36: CostFinalize. Return value 1.
MSI (s) (74:20) [21:49:36:716]: Doing action: CreateUserGuid
MSI (s) (74:20) [21:49:36:716]: Note: 1: 2205 2: 3: ActionText
Action start 21:49:36: CreateUserGuid.
MSI (s) (74:20) [21:49:36:777]: Creating MSIHANDLE (29) of type 790542 for thread 4128
MSI (s) (74:B4) [21:49:36:778]: Creating MSIHANDLE (30) of type 0 for thread 7604
MSI (s) (74:AC) [21:49:36:779]: Generating random cookie.
MSI (s) (74:AC) [21:49:36:809]: Created Custom Action Server with PID 2904 (0xB58).
MSI (s) (74:D4) [21:49:36:969]: Running as a service.
MSI (s) (74:D4) [21:49:36:973]: Hello, I'm your 32bit Impersonated custom action server.
MSI (s) (74!20) [21:49:36:987]: PROPERTY CHANGE: Adding USERGUID property. Its value is
'06520F92-D326-41FE-AAE9-0AC064D745CC'.
MSI (s) (74:B4) [21:49:36:988]: Closing MSIHANDLE (30) of type 0 for thread 7604
MSI (s) (74:B4) [21:49:36:988]: Closing MSIHANDLE (29) of type 790542 for thread 4128
Action ended 21:49:36: CreateUserGuid. Return value 1.


Obviously you can do what you want with the USERGUID property, hope that helps.
Pat Higgins
2008-02-19 10:38:44 UTC
Permalink
Not sure if this will work for you but we've created GUIDs the following way in the past.
<?define SkuPackageCode = "{????????-????-????-????-????????????}"?>

I'm not sure we have example of what you're doing so maybe it'll work & maybe it won't.
<RegistryValue Root="HKCU" Key="Software\<omitted>" Name="UserId" Value="{????????-????-????-????-????????????}" Type="string" Action="write" />


Thx
Pat

From: wix-users-***@lists.sourceforge.net [mailto:wix-users-***@lists.sourceforge.net] On Behalf Of Steve Bush
Sent: 18 February 2008 16:07
To: wix-***@lists.sourceforge.net
Subject: [WiX-users] Create New Guid in Installer

Does anyone know of an easy way in WIX to automatically create a GUID on install? I want to create a GUID that represents the user and place it in the registry. Here's an example:

<RegistryValue Root="HKCU" Key="Software\<omitted>" Name="UserId" Value="<newGuid>" Type="string" Action="write" />


________________________________
About Microsoft Ireland: www.microsoft.com/ireland
Microsoft Ireland Operations Limited. A company incorporated and registered in Ireland number 256796.
Microsoft Ireland Research. A company incorporated and registered in Ireland number 342235.
Registered office 70 Sir John Rogerson's Quay, Dublin 2, Ireland
KStuart
2008-02-19 22:50:07 UTC
Permalink
Not sure if this will work for you but we've created GUIDs the following way
in the past.
<?define SkuPackageCode = "{????????-????-????-????-????????????}"?>

I'm not sure we have example of what you're doing so maybe it'll work &
maybe it won't.
<RegistryValue Root="HKCU" Key="Software\<omitted>" Name="UserId"
Value="{????????-????-????-????-????????????}" Type="string" Action="write"
/>

--

As the <?define ...?> is a preprocessor statement surely it must resolve at
compile time, also that guid pattern appears to be a WiX convenience compile
time feature so I would think it would be replaced with an actual guid
during compilation or linking, it would need to be a Windows Installer
feature to generate the guid at install time, therefore every user that
installed the package would get the same guid.
--
View this message in context: http://www.nabble.com/Create-New-Guid-in-Installer-tp15548559p15577017.html
Sent from the wix-users mailing list archive at Nabble.com.
KStuart
2008-02-19 11:24:32 UTC
Permalink
I'm new to wix and msi but it looks like you'll need to use a custom action,
you could call into a dll or write a
vbscript (it looks like using scripts in custom actions may be frowned
upon), anyway you can set a property to a new
guid and then reference that, the simplest example would be with a vbscript
custom action.

<Product ...>

...

<Binary Id="VbScriptKit" SourceFile="VbScriptKit.vbs"/>
<CustomAction Id="CreateUserGuid" Return="check" BinaryKey="VbScriptKit"
VBScriptCall="CreateUserGuid"/>

<InstallExecuteSequence>
<Custom Action="CreateUserGuid" After="CostFinalize"/>
</InstallExecuteSequence>

...

</Product>

---

VbScriptKit.vbs (make sure this is ASCII)

Option Explicit

Function CreateUserGuid()
Session.Property("USERGUID") = Mid(CreateObject("Scriptlet.TypeLib").GUID,
2,36)
CreateUserGuid = 1
End Function

---

you should make the function more robust but it's just an example.

Here's the relevant snippet of the install log:

Action ended 21:49:36: CostFinalize. Return value 1.
MSI (s) (74:20) [21:49:36:716]: Doing action: CreateUserGuid
MSI (s) (74:20) [21:49:36:716]: Note: 1: 2205 2: 3: ActionText
Action start 21:49:36: CreateUserGuid.
MSI (s) (74:20) [21:49:36:777]: Creating MSIHANDLE (29) of type 790542 for
thread 4128
MSI (s) (74:B4) [21:49:36:778]: Creating MSIHANDLE (30) of type 0 for thread
7604
MSI (s) (74:AC) [21:49:36:779]: Generating random cookie.
MSI (s) (74:AC) [21:49:36:809]: Created Custom Action Server with PID 2904
(0xB58).
MSI (s) (74:D4) [21:49:36:969]: Running as a service.
MSI (s) (74:D4) [21:49:36:973]: Hello, I'm your 32bit Impersonated custom
action server.
MSI (s) (74!20) [21:49:36:987]: PROPERTY CHANGE: Adding USERGUID property.
Its value is
'06520F92-D326-41FE-AAE9-0AC064D745CC'.
MSI (s) (74:B4) [21:49:36:988]: Closing MSIHANDLE (30) of type 0 for thread
7604
MSI (s) (74:B4) [21:49:36:988]: Closing MSIHANDLE (29) of type 790542 for
thread 4128
Action ended 21:49:36: CreateUserGuid. Return value 1.


Obviously you can do what you want with the USERGUID property, hope that
helps.
Post by Steve Bush
Does anyone know of an easy way in WIX to automatically create a GUID on
install? I want to create a GUID that represents the user and place it in
<RegistryValue Root="HKCU"
Key="Software\<omitted>" Name="UserId" Value="<newGuid>" Type="string"
Action="write" />
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
WiX-users mailing list
https://lists.sourceforge.net/lists/listinfo/wix-users
--
View this message in context: http://www.nabble.com/Create-New-Guid-in-Installer-tp15548559p15560554.html
Sent from the wix-users mailing list archive at Nabble.com.
Simon Topley
2008-02-19 15:58:35 UTC
Permalink
I assume you can't use:

????????-????-????-????-????????????

Or maybe set this as the content of a property then use that property.
Seems annoying to have to reinvent the wheel when WIX clearly has the
code to do it.
The information contained in this e-mail is likely to be confidential and
may be legally privileged. It is intended only for the addressee. If you
have received this message in error please notify the sender immediately at
the above address. The disclosure, copying or distribution of this message
or its contents without the prior approval of Wallingford Software is
strictly prohibited. Wallingford Software is not liable for
unauthorised disclosures nor for subsequent actions or omissions in reliance
upon them.

Registered in the UK, company no: 02288719
Wallingford Software Limited, Howbery Park, Wallingford, Oxfordshire, OX10 8BA
DEÁK JAHN, Gábor
2008-02-19 23:18:51 UTC
Permalink
On Mon, 18 Feb 2008 08:07:12 -0800, Steve Bush wrote:

Steve,
Post by Steve Bush
Does anyone know of an easy way in WIX to automatically create a
GUID on install? I want to create a GUID that represents the user
and place it in the registry.
Just write a five-minute custom action in C or your language of choice and put the generated GUID into a property. Actually, you can start with the very simple one linked from the first section of http://www.tramontana.co.hu/wix/lesson1.php and then you can combine it with the equally simple one in http://www.tramontana.co.hu/wix/lesson3.php#3.3 to see how you can put it into a property and use it from WiX.

Bye,
G�bor

-------------------------------------------------------------------
DE�K JAHN, G�bor -- Budapest, Hungary
E-mail: ***@tramontana.co.hu

Continue reading on narkive:
Loading...