From ef40aa9393729c305b13233be1830a9da1a0de39 Mon Sep 17 00:00:00 2001
From: Fyodor Sheremetyev <sheremetyev@gmail.com>
Date: Fri, 15 Mar 2013 16:52:53 +0000
Subject: [PATCH] WiX: Update system PATH environment variable when installing
 per-machine.

Had to create two separate components because System property of Environment element cannot be set on condition.
---
 windows/pandoc.wxs | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/windows/pandoc.wxs b/windows/pandoc.wxs
index cee663962..9ca4b463c 100644
--- a/windows/pandoc.wxs
+++ b/windows/pandoc.wxs
@@ -48,9 +48,26 @@
             Source="..\COPYRIGHT.txt" />
             <File Id="pandocCOPYING" Name="COPYING.rtf"
             Source="..\COPYING.rtf" />
-            <Environment Id="UpdatePath" Name="PATH" Action="set"
-            Part="last" Value="[APPLICATIONFOLDER]" />
           </Component>
+
+          <Component Id="UpdatePathUser"
+            Guid="C7B71304-09FC-421D-9EA2-AEFB7D61759D">
+            <Condition><![CDATA[ ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged)) ]]></Condition>
+            <Environment Id="UpdatePathUser" Name="PATH" Action="set"
+            Part="last" Value="[APPLICATIONFOLDER]" System="no" />
+            <RegistryValue Root="HKCU" Key="Software\John MacFarlane\Pandoc"
+            Name="UserPathUpdated" Type="integer" Value="1" KeyPath="yes"/>
+          </Component>
+
+          <Component Id="UpdatePathMachine"
+            Guid="0C642D0A-7175-4CD7-B11F-0A69F73FD757">
+            <Condition><![CDATA[ ALLUSERS=1 OR (ALLUSERS=2 AND Privileged) ]]></Condition>
+            <Environment Id="UpdatePathMachine" Name="PATH" Action="set"
+            Part="last" Value="[APPLICATIONFOLDER]" System="yes" />
+            <RegistryValue Root="HKLM" Key="Software\John MacFarlane\Pandoc"
+            Name="SystemPathUpdated" Type="integer" Value="1" KeyPath="yes"/>
+          </Component>
+
           <Component Id="Documentation"
           Guid="A8D54A76-1A3D-4647-8327-81B69D39D8A3">
             <File Id="pandocREADME" Name="Pandoc User's Guide.html"
@@ -77,6 +94,8 @@
     <Feature Id="Complete" Level="1" Title="Pandoc $(var.VERSION)" Description="Complete package"  Display="expand" ConfigurableDirectory="APPLICATIONFOLDER">
       <Feature Id="MainProgram" Title="Program" Description="The main executable." Level="1">
         <ComponentRef Id="MainExecutable" />
+        <ComponentRef Id="UpdatePathUser" />
+        <ComponentRef Id="UpdatePathMachine" />
       </Feature>
       <Feature Id="Manual" Title="Manual">
         <ComponentRef Id="Documentation" />