I've seen many people report that they are running powershell custom actions 
successfully but I can't seem to find any examples of how they do it. My goal 
is to run powershell silently. I'm trying to do it as follows:

<DirectoryRef Id="INSTALLDIR">
  <Component Id="SampleScriptPS1" Guid="*">
    <File Id="SampleScriptPS1" Name="SampleScript.ps1"/>
  </Component>
</DirectoryRef>
<Property Id="POWERSHELLEXE">
  <RegistrySearch Id="POWERSHELLEXE"
                  Root="HKLM"
                  
Key="SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell"
                  Name="Path"
                  Type="raw"/>
</Property>
<CustomAction Id="SetPSCmd"
              Property="PSCmd"
              Value="&quot;[POWERSHELLEXE]&quot; [#SampleScriptPS1]"
              Execute="immediate"
              Return="check"/>
<CustomAction Id="PSCmd"
              BinaryKey="WixCA"
              DllEntry="CAQuietExec"
              Execute="deferred"
              Return="check"/>
<InstallExecuteSequence>
  <Custom Action="SetPSCmd" Before="PSCmd"/>
  <Custom Action="PSCmd" After="InstallFiles"/>
</InstallExecuteSequence>

When I run my installer I notice that the progress bar moves to about halfway 
then stops moving. I can see the powershell process in task manager but it is 
not using up any CPU. When I look at the log file (installer is still 
"running") I see the following as the last lines of the log:

MSI (s) (B4:10) [11:33:19:092]: Executing op: ActionStart(Name=PSCmd,,)
MSI (s) (B4:10) [11:33:19:136]: Executing op: 
CustomActionSchedule(Action=PSCmd,ActionType=1025,Source=BinaryData,Target=CAQuietExec,CustomActionData="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
 C:\InstallDir\SampleScript.ps1)

When I get tired of waiting I'll explicitly kill the powershell process which 
allows the installer to continue, the custom action fails, and the installer 
rollsback. When I look at the log again I now see the following immediately 
following the log text above:

MSI (s) (B4:94) [11:33:19:157]: Invoking remote custom action. DLL: 
C:\Windows\Installer\MSI374B.tmp, Entrypoint: CAQuietExec
MSI (s) (B4:2C) [11:33:19:160]: Generating random cookie.
MSI (s) (B4:2C) [11:33:19:180]: Created Custom Action Server with PID 3816 
(0xEE8).
MSI (s) (B4:EC) [11:33:19:282]: Running as a service.
MSI (s) (B4:EC) [11:33:19:289]: Hello, I'm your 32bit Impersonated custom 
action server.
CAQuietExec:  Error 0xffffffff: Command line returned an error.
CAQuietExec:  Error 0xffffffff: CAQuietExec Failed
Action ended 11:37:43: InstallFinalize. Return value 3.

I don't think this is a bug in CAQuietExec as I can use this pattern for 
running other scripts, such as sqlcmd scripts. Am I doing something obviously 
stupid here?

Edwin G. Castro
Software Developer - Staff
Electronic Banking Services
Fiserv
Office: 503-746-0643
Fax: 503-617-0291
www.fiserv.com<http://www.fiserv.com/>
P Please consider the environment before printing this e-mail

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to