How to start PowerShell in WiX with proper access to Windows Registry? -
update
interesting, if run 32bit powershell run script, gives me same error. looks 32bit powershell has no access 64 bit registry tree? tried using wixquietexec64
gave same error. tried providing full path of powershell (c:\windows\system32\windowspowershell\v1.0\powershell.exe
) ensure installer launch 64bit version, still gave same error... looks might caused msi installer being 32bit??
msi (s) (4c:c0) [14:25:49:955]: hello, i'm 32bit elevated non-remapped custom action server.
original post
i have following test.ps1
script:
$exchangeroot = "hkey_local_machine\software\microsoft\exchangeserver\" $allexchanges = get-childitem -path registry::$exchangeroot -name | where-object { $_ -match "^v.." } $sorted = $allexchanges | sort-object -descending if ($sorted.count -gt 1) { $latest = $sorted[0] } else { $latest = $sorted } $setup = $exchangeroot + $latest + "\setup" $properties = get-itemproperty -path registry::$setup $properties
running script in normal powershell windows yields following output:
ps c:\program files (x86)\trustvalidator exchange server plugin> .\test.ps1 required machine-level settings. : 1 services : c:\program files\microsoft\exchange server\v15 newestbuild : 10845 currentbuild : 710737954 information store service : 1 messaging , collaboration event logging : 1 msiinstallpath : c:\program files\microsoft\exchange server\v15\ ...
so works. launching powershell wix installer , executing script, doesn't generate same result:
wixquietexec: get-itemproperty : cannot find path wixquietexec: 'hkey_local_machine\software\microsoft\exchangeserver\v15\setup' because wixquietexec: not exist. wixquietexec: @ c:\program files (x86)\trustvalidator exchange server plugin\test.ps1:10 wixquietexec: char:16 wixquietexec: + $properties = get-itemproperty -path registry::$setup wixquietexec: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wixquietexec: + categoryinfo : objectnotfound: (hkey_local_mach...erver\v15\set wixquietexec: up:string) , itemnotfoundexception wixquietexec: + fullyqualifiederrorid : pathnotfound,microsoft.powershell.commands.getit wixquietexec: empropertycommand
now if observe error message, though has access of tree until hkey_local_machine\software\microsoft\exchangeserver\
, because script search , list versions, v15
has accessible point, when tries go deeper itemproperty
, can't.
this lead me believe perhaps i'm missing when launching powershell wix installer...?
this what's in wxs file:
<setproperty id="installplugin" before ="installplugin" sequence="execute" value =""powershell.exe" -command "cd '[installfolder]'; & '[#testps1]' ; exit $$($error.count)"" /> <customaction id="installplugin" binarykey="wixca" dllentry="wixquietexec" execute="deferred" return="ignore" impersonate="no" />
below list of items i've tried or double checked:
- i've tried different combinations of
-noprofile
,-executionpolicy bypass
,-version 2.0
, still no good. - i'm running installer
installprivileges="elevated"
- i'm running
customaction
execute="deferred"
,impersonate="no"
- i've tried
adminimage="yes"
- i've tried setting
<property id="msiuserealadmindetection" value="1" />
any other clue appreciated. :(
oh... my... god...
ok got working. there several problems , solutions these problems in bits , pieces of information gather across multiple questions.
to recap, here trying do:
- launch powershell wix run install script.
- my script search windows registry (requires 64bit) installed exchange server's location
- my script loads exchange management shell (ems) script (requires 64bit , proper user) install location
- under ems session, script run brunch of other scripts register exchange plugin
problem 1)
no matter did, wix installer launches powershell in 32bit, regardless of setting platform="x64"
, win64="yes"
, , wixquietexec64
. built installer in visual studio x64
, everything else x64
.
the solution directly reference sysnative
powershell, has sysnative
in setproperty
.
c:\windows\sysnative\windowspowershell\v1.0\powershell.exe
i did tried before, , thought wasn't working, root cause being masked problem 2 below.
problem 2)
everywhere read, said need run execute="deferred" impersonate="no"
. believe indeed work cases if not doing funky. however, had to impersonate
. discovered wix installer run ca elevated user nt authority/system
. screwed me on because exchange management shell
script trying source use credential , try establish session exchange server... , of course can't connect nt authority/system
!
the solution use impersonate="yes"
wix installer run ca elevated , user logged in. had impression must use impersonate="no"
when using execute="deferred"
... but don't.
i gave troubleshoot few days , went , got working. 2 helpful commands helped me figured out actually:
- whoami
- get-childitem env: (to check processor_architecture)
Comments
Post a Comment