Is there a way to start Explorer from a rollback custom action in WiX? - wix

Because of some dependencies, we close Windows Explorer during part of our installation. As an emergency safety, I'd like to make sure that the user has a shell if we fail. I thought that a type 34 custom action with 'Execute="rollback"' was what I wanted to do, but I don't seem to be smart enough to craft the CA.
Here's what I have:
<CustomAction Id="RestartExplorer"
ExeCommand="explorer.exe"
Execute="rollback"
Impersonate="yes"
Return="asyncNoWait"/>
I know I'm missing a directory element, but I don't know how to specify a platform agnostic way of specifying %windir%\system32. Using environment variables or scripting is not an option.
Thanks :)

I've never tried to kill Explorer during an install. Doesn't it autorestart? What if it restarted while you were installing?
Otherwise, if I did do this, I'd start it back up using the QuietExec custom action.
You would also want to start it as an immediate custom action after InstallFinalize. Note I didn't say commit because rollback can be disabled and commit wouln't execute.
Also the SystemFolder property is what you are looking for. Make sure you test this on 32 and 64 bit machines.

Killing explorer is the wrong thing to do in any case that I can think of. Instead of restarting explorer, I fixed the bug in our shell extension ;) Thank you for your help

Related

Restart system after doing a custom action in wix

I have a requirement to execute a script and after perform it I want to restart the system. In my custom action project, I added a checking for executing the corresponding scripts. I want to restart the system when I execute the one script. This script executed only when certain conditions are satisfied only.
Please guide me for resolving this issue.
Regards,
George
I have created another custom action dll for doing the restart operation after performing a certain condition level passed. Then called this custom action in InstallExecuteSequence after installation.
Its working fine as I expected level.
Thank you all.

Launch condition in WIX to check advertise mode

I am running my MSI from command prompt with /jm option. I want to add a LaunchCondition in my WIX file to check whether the MSI is triggered with /jm option.
Thanks in advance.
https://wixtoolset.org/documentation/manual/v3/xsd/wix/advertiseexecutesequence.html
Try using the AdvertiseExecuteSequence tag. You can create an error action to prevent any advertised installations from taking place. Just place the error at the beginning of the sequence.
Initialize the error action:
<CustomAction Id="ErrorMessageId" Error="Insert error message here"/>`
Run the error action:
<AdvertiseExecuteSequence>
<Custom Action="ErrorMessageId" Before="CostInitialize"/>
</AdvertiseExecuteSequence>
Every feature can go into advertised state. One easy way would be to edit the .msi, if possible and add the "msidbFeatureAttributesDisallowAdvertise" (8) and maybe the "msidbFeatureAttributesUIDisallowAbsent" (16) attribute to the MSI feature table. (I don't work with WiX so you will find out yourself).
Another way would be to add a custom action who controls if the ADVERTISE property is nonempty and just abort the installation.
Changing the feature action from advertise to install local would be quite tricky but maybe possible.
If you have a path (.msp) there are other ways to protect it from being installed with features in advertised mode.

WiX Shell Command Conditional Installation

I'm new to WiX (and Windows development in general), and I'd like to add logic to my installer that will cause the installation to fail with a friendly error if the shell command fails. I've seen the ShellExecute CustomAction and instructions for Conditional Installation, but I'm not sure how to tie these together.
I prefer to write my own Custom Action in either VbScript or C# while calling API method ShellExecute. In this way, we have good control over its return code (if ShellExecute fails) and we can display our own user friend message and terminate the installation (or set it to roll back).
Here is an example not specific to ShellExecute, but how to quit from Installation while showing your own user friend message:
http://devdare.blogspot.com/2012/07/how-to-quit-installation-from-vbscript.html
For using ShellExecute in VBScript Custom Action:
http://ss64.com/vb/shellexecute.html
Hope this helps.

automate, unattended or silent installation of a software

I have a software. It has GUI setup for windows and CLI install.sh for linux. On execution it asks user to accept license and on acceptance it asks for installation location, key, server ip, port, and a couple more option one after the other. I want to make the installation unattended so that the user double click a file and the next step is software installed. Any suggestions, thanks in advance.
The answer depends on what InstallShield project type you are using. I highly suggest Basic MSI. InstallScript custom actions are OK but don't use an InstallScript or InstallScript MSI project type.
Assuming the above, you create Secure Custom Public Properties so they can be passed at the command line. You also create custom dialogs so that the values can be entered during an interactive installation. Then you create validation custom actions that can guard against bad data in both scenarios. Finally you use the properties in Registry, INI, XML et al system changes so that they can be applied where needed for your application.
Your silent install then looks like:
msiexec /I foo.msi /qn INSTALLDIR=C:\FOO KEY=12345 SERVERIP=10.0.0.1
PORT=12345 /l*v install.log
Also be sure to understand the concept that properties aren't persisted automatically by MSI. You'll need some AppSearch/System Searches to retrieve the stored values for reuse during upgrade / patch / repair scenarios.
What you need is called Silent mode. Check your installation system's manual for this keyword.
Many installation systems support it - I can recommend you to use NSIS (/SILENT parameter) or Inno Setup (/SILENT, /VERYSILENT) if you did not started with creating your setup yet.
These are free (open source) installation systems and they are really powerful.
Be careful with this feature - many users are confused when they click the application icon and nothing happens (no window opens).
Ok I did this using expect tool (free). Here install.sh is the file I want to execute automatically and send are my options in response to the questions it asks during installation. Let me know if any problem following this.
!/usr/local/bin/expect
spawn "./install.sh"
set timeout 2
expect {WARNING: It is strongly recommended that you install RVS as root. Do you wish to run the installer as root [Y/n]}
send "Y\r"
send "xxxxxx\r"
expect {Press enter to read the License Agreement:}
send "ENTER\r"
expect {Do you accept the License Agreement [y/N]?}
send "y\r"
expect {Where do you want to install the tools [/usr/local/pkg/RVS/v3.1a]?}
send "ENTER\r"
expect {Where do you want to create links for tools [/usr/local/bin]?}
send "ENTER\r"
expect {Where do you want to create links for libraries [usr/local/lib]}
send "ENTER\r"
expect {Which license type do you wish to use [N/f/a]?}
send "f\r"
expect {IP address:}
send "1.1.1.1\r"
expect {Port:}
send "33\r"
expect {SERVERKEY}
send "xxxxxxxxxxxx\r"
expect {Do you want to install support for GNAT Pro {6.0, 6.1, 6.4} (You need a GNAT Pro license in order to use this feature) [y/N]?}
send "y\r"
expect {Proceed with the installation [Y/n]?}
send "y\r"
spawn "rvsinfo"
interact

NSIS: Detecting Tomcat Installation

I have been trying to detect if Tomcat is installed on a host system in my NSIS script.Here is the section that does it
Section Tomcat
ClearErrors
Var /GLOBAL tomcatVersion
ReadRegStr $tomcatVersion HKLM "SOFTWARE\Apache Software Foundation\Tomcat\7.0\Tomcat7" "InstallPath"
;ExecWait "$EXEDIR\apache-tomcat-7.0.22.exe"
DetailPrint "$tomcatVersion"
SectionEnd
When I go to "regedit" and check the path of that specific key, it has a value, but the print statement returns a blank.
Can someone suggest what is the best way to troubleshoot this and/or any errors that I might be facing?
There is an interesting thing I noticed, that If in the above code, if I point the ReadRegStr command to read
HKLM "SOFTWARE\JavaSoft\Java Runtime Environment" "CurrentVersion"
It returns a value, so syntactically, the code does work.
If the Tomcat installer is a 64 bit installer then a 32 bit process will not find that key, in NSIS you can use SetRegView 64.
If you are using RequestExectionLevel in your script and the Tomcat installer was virtualized by UAC then you must read it from the VirtualStore (Unlikely in your case since you can see the key in regedit)
Process Monitor is also handy to debug registry issues...
A little late to the party, but this thread comes up if you google for "nsis install tomcat", so I thought I would share this nice example I found...
https://github.com/mathiaslin/openmrs-pgh-190/blob/master/metadata/installer/installer_setup.nsh