In WiX,
Is it possible to force using some flags like /NORESTART with or without using command line?
In other words, I want to create MSI package which always has /NORESTART flag applied, no matter is executed by double click or from CMD
Thanks for help.
As I know it's possible to set few InstallRunMode variables via custom actions.
session.SetMode(InstallRunMode.RebootNow, false);
session.SetMode(InstallRunMode.RebootAtEnd, false);
Update:
Also, it's possible to do it using bootstrapper application by passing /NORESTART to MsiPackage.
Related
In my company I create apps that are shared by many different products. For instance a help application.
A requirement is that I create an MSI with WiX that can be consumed by the main installers for each product. This MSI receives variables from the main installers so that it installs and uninstalls properly.
Because of this, I want to restrict having the MSI run by itself. That is, someone double clicking on it, etc.
Is there a way I can prevent it from running on its own and display a message of some type to the user?
I am completely new to WiX and I really appreciate your help.
You can set a public property which blocks the installation of the product by default - i.e. if a user were to attempt to install it by double-clicking.
<Condition Message="test">BLOCKINSTALL = 1</Condition>
<Property Id="BLOCKINSTALL" Value="0"/>
This blocks install by default. The property can then be changed by your other installers, or by calling:
msiexec /package Installer.msi BLOCKINSTALL=1
This will allow you to change the blocking value, allowing the installation to progress.
I want to execute the below lines of code through WIX and here is the code where am able to do it through the command prompt:
dism.exe /online /enable-feature:NetFx3 /quiet /norestart -----> To enable
dism /online /get-featureinfo:netfx3 ------> To verify the value
If all that you want to do using Wix is to launch executables, Wix/windows installer provides multiple ways to do that.
I generally prefer using Quite Execution custom actions provided by the Wix toolset. Reason being, it allows me to launch executables without displaying any console windows, which otherwise would have required me to write custom action code.
Take a look at :
http://wixtoolset.org/documentation/manual/v3/customactions/qtexec.html
The examples in the above URL are sufficient enough to help you get started.
In order to use QtExec (Quite execution custom actions), you must include a reference to the WixUtilExtension when building your MSI. To do this, add the command line argument -ext WixUtilExtension.dll when calling Light.exe.
I installed an test application which has two features (FirstFeature & SecondFeature). I want to remove only one feature (SecondFeature) from the application. I tried using REMOVE property in command line. Here is the command used to remove SecondFeature.
msiexec /x RemoveFeatures.msi REMOVE="SecondFeature" /L*V log.LOG
But it is uninstalling the complete application. Log file shows that REMOVE=ALL is added by default. Here is the log file details.
MSI (s) (24:B4) [17:39:05:231]: Command Line: REMOVE=SecondFeature REMOVE=ALL
MSI (s) (24:B4) [17:39:05:231]: PROPERTY CHANGE: Adding REMOVE property. Its value is 'SecondFeature'.
MSI (s) (24:B4) [17:39:05:231]: PROPERTY CHANGE: Modifying REMOVE property. Its current value is 'SecondFeature'. Its new value: 'ALL'.
It indicates REMOVE property value is overridden during uninstall process. Do I need to set any other property to remove a specific feature ?
Any help is appreciated. Thanks in advance !!!
As you noted, /x is for uninstall. A complete (ALL) uninstall.
Although it may be counter intuitive you want to do an install that removes a feature.
msiexec /i RemoveFeatures.msi REMOVE="SecondFeature" /L*V log.LOG
You may also wish to add /qb or /qn to make it non-interactive / silent.
I have a situation where I have been asked to re-implement and InstallShield installer in Wix. I am having difficulty with examples on the Internet trying to implement the exact behavior. What I need to do is the following:
When the user clicks the Install button on the VerifyReadyDlg (I am using Mondo) and the ProgressDlg comes up:
Call a .exe in the install location (if exists from a previous install)
Stop a service in the install location (if exists from a previous install)
Unregister the said service (if exists from a previous install)
Copy files from the MSI, including a copy of the service .exe to install location
Read data from some Edit controls on a previous dialog and write the data to some of the copied .xml configuration files that are now in the install location
Register the service again
On clicking the Finish button on the very final dialog (ExitDlg) I need to:
Start the service again
Call an .exe (different to the first one) in the install location
I can copy files and write data to some of the files after they have been copied...though Wix just does this...I don't tell it when to go and do it. The problem is I need to schedule the first .exe call, Service Stop and Unregister before the Copy action starts and I can only Register again AFTER the .xml config files have been updated.
I have been trying to use InstallExecuteSequence and ServiceInstall elements and tying them together with CustomActions, but it's not coming together and I think I am totally approaching this the wrong way...it's not worth posting what I have done.
How should I go about this? This is a common pattern that I have seen in InstallSheild scripts, yet I can't find any Wix examples doing this sequence.
Thanks a HUGE bunch for any help on this.
Michael.
You can control when your actions are scheduled using Before or After attributes of Custom element or the elements for standard actions.
Is the current installation made with MSI? If yes, you may want to do upgrade installation and schedule RemoveExistingProducts after you copy existing config but before other install actions are performed. This way the previous package will be removed with its own uninstall logic, and then you can install the updated package.
To save configuration from the previous version, you have to run an action before RemoveExistingProducts is executed.
You may wish to use a Custom Action that you define in C# from a project you create that outputs to a DLL file:
public static class CustomActions
{
[CustomAction]
public static ActionResult DoSomething(Session session) {
// Put C# code here that does what you describe, such as run an exe
// from the command prompt.
return ActionResult.Success;
}
}
Import this DLL into your Wix installer:
<!-- The custom action DLL itself.-->
<Binary Id="WebAppCA" SourceFile="$(var.SolutionDir)..\WebAppInstallCustomActions\bin\Debug\WebAppInstallCustomActions.CA.dll" />
<!-- The custom action that does something that you can use. -->
<CustomAction Id="DoSomething"
BinaryKey="WebAppCA"
DllEntry="DoSomething"
Execute="immediate"
Return="check" />
If you wanna check out a complete solution, see this thread on John Robbins' Blog (link)...he has a Wix installer that installs an IIS site but when you start it, it uses a Custom Action defined in C# to enumerate a list of web sites.
So I have a Wix 3.0 project that installs an IIS7 Native Code Module. When uninstalling I would like to be able to shut down the IIS7 application pools before deleting the file so that a reboot is not necessary.
I am using the appcmd utility to shut down the app pools in a CustomAction element, but when I attempt to do an uninstall I get this error before the customaction is ever invoked:
The setup must update files or
services that cannot be updated while
the system is running. If you choose
to continue, a reboot will be required
to complete the setup.
I have the "After='InstallInitialize'" property set on the CustomAction, because the documentation says that any deferred/not-impersonated custom action must come between InstallInitialize and InstallFinalize.
So is there some way to have a custom action execute before this check for files in use is made? Or disable this check for a given file, or make the check happen later in the sequence?
Yes, you can specify the order for actions to occur by modifying the Sequence column in the InstallExecuteSequence table within the MSI file.
Get the ORCA tool to examine the MSI file to see what I mean, and use a Javascript script to modify the MSI as appropriate.