skj
Posts: 40
Joined: Thu Apr 07, 2005 11:08 am

Restart condition

need on the end of uninstallation to check if some registry key exist,
and if yes I want to display message box with restart prompt.

I have only small knowledge about custom action and launch conditions.
Can you give me tip what to add into my *.msi wizard project to solve this
task ?
UdreaMihai
Posts: 90
Joined: Wed Mar 23, 2005 8:13 am

Hi,

You can use a search (from "Search" page -> "New Search" and then "Add Location">"Registry") to set a property (named let's say MYPROP). But this search will be performed at the beginning of the uninstall and you can only get the value data from a registry key value you can't test the existence of a registry key.

If you decided to use the search for a registry value at the beginning of the uninstall then from "Custom Action" page use "Show Standard Action">"Before Finalization">"InstallFinalize". Now under "InstallFinalize" use "New Custom Action">"Property Set with Formated".
for the "Property Name" use: REBOOT
for the "Formatted Text" use: Forced
for the "Expression" use: MYPROP="aspected value to reboot"

If you consider that the search for a registry value at the beginning of the uninstall doesn't satissfayes your needs you must create a custom action that will test the registry at the end of the uninstall and will set that property. If you will use scripts see MSDN for more information about using registry in scripts:
http://msdn.microsoft.com/library/defau ... egread.asp
But not all scripts that run from Explorer also run from WindwsInstaller and vice-versa. For example:
in Explorer you can use:
Set WshShell = WScript.CreateObject("WScript.Shell")
in WindowsInstaller you must use:
Set WshShell = CreateObject("WScript.Shell")

and if you want to set the reboot from a custom action use:
Session.Property("REBOOT") = "Forced"

Let me know how it works.

Best,
Mihai.
Udrea Mihai
Advanced Installer Team
http://www.advancedinstaller.com
dmh_nrltd
Posts: 20
Joined: Mon Dec 12, 2005 5:35 pm

Hi,

On a similar topic, I'm trying to conditionally force a reboot after an install.

I would like to run a utility to check whether a reboot is required, and then force a reboot based on the return code of the utility (or some other notification from the utility).

Can this be done, and what's the best method?

Thanks,
David.
ciprian
Posts: 259
Joined: Thu Jul 14, 2005 12:56 pm
Location: Craiova, Romania
Contact: Website

Hi David,

This could be achieved with the use of two custom actions.

The first custom action would execute a script that runs the utility program and retrieves the return code. Depending on the return code the REBOOT property will set be accordingly.

For an example of a VbScrip that runs an EXE and retrieves the return code please visit:
http://www.advancedinstaller.com/forums ... .php?t=916

In the previous post it is described how to set this property.

For additional information please see:
http://www.advancedinstaller.com/user-g ... -page.html

Best regards
Ciprian
Ciprian Burca
Advanced Installer Team
http://www.advancedinstaller.com
dmh_nrltd
Posts: 20
Joined: Mon Dec 12, 2005 5:35 pm

Hi and thanks for the reply.

Can I clarify a couple of things? There are two things I'm trying to achieve:

1) At the start of install, I wish to run a utility (attached) and check the return code, then proceed with install if the return code is 0. If the return code is non-zero, I'd like to display an error message and halt the install.

Steps:
- Set the path for the utility (with a custom actions? not sure how ...)
- Custom action (vbs) to execute the utility and set a property on the return code value, plus display an error if we are going to stop
- I'm guessing that if the above CA returns non-zero the install will halt.

2) At the end of install, I wish to run another utility and check the return code. If non-zero, I'd like to force a reboot.

Steps:
- Custom action to set the path of the utility to a property
- Custom action (vbs) to run the utility and set the REBOOT if required

Are these steps correct?

Particularly, for (1) how do I get the name / path of an attached exe through to the VBS script (is this possible?). I want to run this before installing, so the utility is not yet installed.

Thanks in advance,
David

Return to “Common Problems”