Your response was the key.  The "Directory" attribute does matter.  Since the 
directory specified doesn't exist "BeforeFinalize", the command fails.  I 
changed the directory to one that does exist after the installer completes and 
the current script works fine.

Thanks!

-----Original Message-----
From: Phil Wilson [mailto:phil.wil...@mvps.org] 
Sent: Friday, May 10, 2013 3:22 PM
To: 'General discussion for Windows Installer XML toolset.'
Subject: Re: [WiX-users] When are elevated permissions dropped?

Ok, I missed that. You mean the run of netsh.exe? That's not what is usually 
referred to as a script (as in vbscript etc).  Your INSTALLFOLDER won't exist 
by the time you run that custom action because it's after RemoveFolders. I 
don't think that should make a difference, but it's possible that Windows does 
something like setting the executable's working directory to that folder. 

It looks like you need a verbose log. Experimentally you can keep moving the 
custom action down the sequence until it starts failing. Or try after 
RemoveFolders to see if that's where it starts to fail. 

Phil 

-----Original Message-----
From: Brownfield, Cory [mailto:cbrownfi...@aeci.org]
Sent: Friday, May 10, 2013 12:31 PM
To: General discussion for Windows Installer XML toolset.
Subject: Re: [WiX-users] When are elevated permissions dropped?

The script included in my email doesn't work on Windows 7.  It's pretty simple 
(no environment variables, etc.).  It produces an MSI that can be installed but 
not uninstalled.

-----Original Message-----
From: Phil Wilson [mailto:phil.wil...@mvps.org]
Sent: Friday, May 10, 2013 10:22 AM
To: 'General discussion for Windows Installer XML toolset.'
Subject: Re: [WiX-users] When are elevated permissions dropped?

It's more likely related to something that is no longer correct during the 
uninstall. Between DeleteServices and InstallFinalize the items that are 
uninstalled include registry entries, type libraries, environment variables, 
files, and folders. 

Deferred and before InstallFinalize basically means that nothing of your 
product is left behind, so I would look for something your script requires that 
is no longer there. Permissions don't change in that area of the uninstall.

Phil  

-----Original Message-----
From: Brownfield, Cory [mailto:cbrownfi...@aeci.org]
Sent: Friday, May 10, 2013 7:37 AM
To: wix-users@lists.sourceforge.net
Subject: [WiX-users] When are elevated permissions dropped?

To illustrate a problem I'm having with a real project, I created a test script 
that runs a custom action that requires elevated privileges during uninstalls.  
If I configure it to run before "InstallFinalize" (deferred, no impersonation), 
the uninstall fails to complete.  The event log says "A program run as part of 
the setup did not finish as expected" and indicates the program being called by 
the custom action.  Changing it to run after "DeleteServices" works.  I think 
that this indicates a problem with permissions.  Shouldn't the elevated 
permissions remain before "InstallFinalize"?

Here's the script.  The custom actions and the install execute sequence are the 
interesting parts:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi";>
  <Product Id="*"
           Name="Foo2"
           Language="1033"
           Version="1.0.0.0"
           Manufacturer="Foo"
           UpgradeCode="55369FED-96BF-4D95-99E4-E7D746A54C62">
    <Package InstallerVersion="200"
             Compressed="yes"
             InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is 
already installed." />
    <MediaTemplate />
    <Condition Message="You need to be an administrator to install this 
product.">Privileged</Condition>

    <Feature Id="ProductFeature"
             Title="FooInstaller"
             Level="1">
      <ComponentGroupRef Id="ProductComponents" />
    </Feature>

    <CustomAction Id="AddEndpoint"
                  Execute="deferred"
                  Directory="INSTALLFOLDER"
                  ExeCommand="[SystemFolder]netsh.exe http add urlacl 
url=http://+:49260/Foo2/ user=\Everyone"
                  Impersonate="no"
                  Return="check" />
    <CustomAction Id="DeleteEndpoint"
                  Execute="deferred"
                  Directory="INSTALLFOLDER"
                  ExeCommand="[SystemFolder]netsh.exe http delete urlacl 
url=http://+:49260/Foo2/";
                  Impersonate="no"
                  Return="check" />

    <InstallExecuteSequence>
      <!-- Configure http ports -->
      <Custom Action="AddEndpoint"
              Before="InstallFinalize"><![CDATA[NOT Installed]]></Custom>
      <Custom Action="DeleteEndpoint"
              Before="InstallFinalize"><![CDATA[Installed AND NOT 
REINSTALL]]></Custom>
    </InstallExecuteSequence>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR"
               Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER"
                   Name="Foo2" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents"
                    Directory="INSTALLFOLDER">
      <Component Id="ProductComponent">
        <File Id="HelloFile"
              Name="HelloFile.txt"
              Source="hello.txt" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>
----------------------------------------------------------------------------
--
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the 
definitive new guide to graph databases and their applications. This 200-page 
book is written by three acclaimed leaders in the field. The early access 
version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users



----------------------------------------------------------------------------
--
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the 
definitive new guide to graph databases and their applications. This 200-page 
book is written by three acclaimed leaders in the field. The early access 
version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

----------------------------------------------------------------------------
--
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the 
definitive new guide to graph databases and their applications. This 200-page 
book is written by three acclaimed leaders in the field. The early access 
version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users



------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the 
definitive new guide to graph databases and their applications. This 200-page 
book is written by three acclaimed leaders in the field. The early access 
version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to