Trying to run the multiple powershell scripts from wix installer - windows

Here I have tried something but it dose not work at all can anyone guide me how to run the multiple scripts from installer
<SetProperty Id="PS1"
Before="PS1"
Sequence="execute"
Value =""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"-NoLogo -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File "-Command "cd '[INSTALLLOCATION]'; & '[#ps1]' ; exit $$($Error.Count)"" />
<CustomAction Id="PS1"
BinaryKey="WixCA"
DllEntry="WixQuietExec"
Execute="deferred"
Return="check"
Impersonate="no" />
<InstallExecuteSequence>
<Custom Action="PS1" After='InstallFiles'>
<![CDATA[NOT Installed]]>
</Custom>
</InstallExecuteSequence>
to destination folder files get copied but it said like this why I dont know ,Inside a log file it shows like this
WixQuietExec: Processing -File '-Command cd' failed because the file does not have a '.ps1' extension. Specify a valid Windows PowerShell script file name, and then try again.
WixQuietExec: Windows PowerShell
WixQuietExec: Copyright (C) Microsoft Corporation. All rights reserved.
WixQuietExec:
WixQuietExec: Try the new cross-platform PowerShell https://aka.ms/pscore6
WixQuietExec:
WixQuietExec: Error 0xfffd0000: Command line returned an error.
WixQuietExec: Error 0xfffd0000: QuietExec Failed
WixQuietExec: Error 0xfffd0000: Failed in ExecCommon method
CustomAction PS1 returned actual error code 1603 (note this may not be 100% accurate if translation happened inside sandbox)

This doesn't always happen, but the error message is pretty clear. Here it is word-wrapped, so it is easier to read:
WixQuietExec: Processing -File '-Command cd' failed because
the file does not have a '.ps1' extension.
Specify a valid Windows PowerShell script file
name, and then try again.
That's a PowerShell error message.

Related

how to run WixSilentExecCmdLine to run batfil ein background

I am trying to run a bat file in background while installing an app using WIX. For this I used WixSilentExecCmdLine but after writing this code sniphet Installationitself failed.
<Property Id="WixSilentExecCmdLine" Value="C:\SampleWix\myBat.bat" Hidden="yes"/>
<CustomAction Id="SilentExecExample" BinaryKey="WixCA" DllEntry="WixSilentExec" Execute="immediate" Return="check"/>
<InstallExecuteSequence>
<Custom Action="SilentExecExample" Before="InstallFinalize"/>
</InstallExecuteSequence>
Light Command
%WIX_LIGHT% %INSTALLER_BUILD_DIR%\*.wixobj -o %OUTPUT_DIR%\%MSI_OUTPUT_FILE_NAME% -ext WixUIExtension -ext WixUtilExtension.dll
You will not be able to run another parallel install while in the ExecuteSequence. Windows installer has a limitation that only one install can be in the ExecuteSequence at one time.
Please see this thread.

Running Powershell script in WiX install as an Administrator

I have a WiX installer that needs to run a Powershell script after install. I've gotten to the point where the installer does in fact run the script with this:
<SetProperty Id="RunStartScript"
Before ="RunStartScript"
Sequence="execute"
Value=""C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NonInteractive -ExecutionPolicy Bypass -InputFormat None -NoProfile -File "[INSTALLDIR]Scripts/Start.ps1"" />
<CustomAction Id="RunStartScript" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="yes" />
<InstallExecuteSequence>
<Custom Action="RunStartScript" Before="InstallFinalize">NOT Installed OR UPGRADINGPRODUCTCODE</Custom>
</InstallExecuteSequence>
However, the msi fails with this error:
The script 'Start.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try running the script again.
The installer already prompts for an Administrator before install begins, so I assumed the PowerShell command would be running as an admin already, this must not be the case.
I've found some answers that involve adding code to the start of a script to check for Admin privileges and to pass the command and args along to an Admin session, but I was looking for the possibility of another option as this is a signed script that someone else provided so any changes to it would have to go back to them for re-signing.
Needed to change Impersonate="yes" to Impersonate="no" so that the Powershell session wasn't ran as the normal user.

Package Manager Console Not Working

I have checked extensively for a solution to the below error to no avail.
When opening Package Manager Console in Visual Studio, I receive an error stating that "There was an error in loading the format data file.. Path --> to file" cannot be loaded because its execution is blocked by software restriction policies. For more information contact your administrator.
These are all of the things i've done to correct but failed.
Running Powershell as an Administrator.. I Set-ExecutionPolicy to RemoteSigned and Unrestricted in powershell(x86), powershell ISE (x86) and also both 64bit versions..
Running Powershell as an Administrator.. I Set ExecutionPolicy -scope for process, currentuser and localmachine to RemoteSigned and Unrestricted.
Reinstalled Visual Studio.
Set the ExecutionPolicy in Registry Editor to RemoteSigned and Unrestricted.
But I am still getting the error.. Can someone please help..
Thanks
Let me know if you tried the following:
PowerShell says "execution of scripts is disabled on this system."
http://sqlish.com/file-ps1-cannot-be-loaded-because-the-execution-of-scripts-is-disabled-on-this-system-please-see-get-help-about_signing-for-more-details/
Powershell profile.ps1 cannot be loaded because its operation is blocked by software restriction policies
if all fails do the below:
It's possible that you changed the execution policy for 64-bit
powershell and the package manager is running 32-bit (or vice versa).
I'd try opening 32-bit console (PowerShell (x86)) and setting the
execution policy there, as the error is definitely pointing to that
kind of resolution.
Make sure you restart visual studio after changing execution policy so
that changes can take effect. Also make sure you changed execution
policy globally with administrator username and password.
Source:file cannot be loaded because the execution of scripts is disabled on this system
As a workaround, I found this solution (more details at stackoverflow.com/a/53433786/8358565)
Execute the following commands in the Package Manager Console
Set-ExecutionPolicy -Scope Process Bypass
Import-Module "your-solution-directory/packages/EntityFramework<your EF version>/EntityFramework.psd1"

Silent Install of Oracle using WiX

I am creating an Installer using WiX, and as part of this I am installing Oracle also.
I am using CA for doing this. But it fails without executing.
<CustomAction Id="InstallORA" ExeCommand="[ORACLE]start-oraclexe-install.bat" Directory="ORACLE" Execute="deferred" Return="check" Impersonate="no" />
My bat file content is:
C:\xe-10.2.0.1-nt.exe /s /f1"C:\OracleXE-install.iss" /f2"C:\oraclexe-setup.log"
In logs I see MSI (s) (44:9C) [12:18:42:344]: Running as a service. after this it pops an error message.
Any ideas how to fix it?

Why PowerShell threw registry access error when setting execution policy rights?

I tried to set execution policy rights in PowerShell to enable the execution of scripts using this Cmdlet,
PS C:\> Set-ExecutionPolicy Unrestricted
but the PowerShell console gave the Registry access denied error. The syntax seems to be okay. Did i overlook something. Please advise.
You should run PowerShell with elevated permissions. Simply right click Windows PowerShell and click Run as Administrator to open PowerShell in elevated privilege.

Resources