Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Cancel msiexec in silent mode


7 replies to this topic

puyopuy

puyopuy
  • Full Members
  • 1 posts

Posted 01 October 2010 - 01:29

Hi Guys,

Just wonder if I running msiexec.exe with silent witch /q, is there a way to cancel that process? I know that if running with UI, I can press Cancel button to cancel it anytime and MSI installer will rollback the changes. Is there any API call or custom actions can archive that?

Thanks for your help

Puyo

VBScab

VBScab
  • Full Members
  • 436 posts

Posted 01 October 2010 - 08:55

There is almost bound to be a way to intercept the API calls being made by MSIExec and "send" it the cancellation but I shudder at the prospect of coding such a thing.
- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 07 October 2010 - 13:25

If you're writing the MSI and intend to cancel the installation, just generate an error (for instance, by running a Custom Action type 19).
If you're calling the MSI, do not use Msiexec but write a program that calls MsiInstallProduct. But before that, install a UI handler that gets notified for every attempt by the Windows Installer to communicate with the outer world (eg. show progress, show message box, etc.) When the handler gets called you can tell Windows Installer it should cancel.
I believe the call is MsiSetExternalUI.

Eugene82

Eugene82
  • Full Members
  • 6 posts

Posted 27 October 2010 - 07:41

QUOTE (Zweitze @ 2010-10-07 13:25)
If you're writing the MSI and intend to cancel the installation, just generate an error (for instance, by running a Custom Action type 19).
If you're calling the MSI, do not use Msiexec but write a program that calls MsiInstallProduct. But before that, install a UI handler that gets notified for every attempt by the Windows Installer to communicate with the outer world (eg. show progress, show message box, etc.) When the handler gets called you can tell Windows Installer it should cancel.
I believe the call is MsiSetExternalUI.

External UI is just one method to cancel silent installation.

VBScab

VBScab
  • Full Members
  • 436 posts

Posted 27 October 2010 - 08:41

That's a useful response. Shall the OP just guess at the others or will you actually share?
- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

Eugene82

Eugene82
  • Full Members
  • 6 posts

Posted 27 October 2010 - 09:49

i means it is single method to cancel silent installation. Others methods doesn't exists. Sorry for my english)

VBScab

VBScab
  • Full Members
  • 436 posts

Posted 27 October 2010 - 17:11

No, it's my mistake: I apologise.

The correct English, then, would have been:

MsiSetExternalUI is the only method for cancelling a silent installation
- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 05 November 2010 - 12:34

QUOTE (VBScab @ 2010-10-27 07:41)
That's a useful response. Shall the OP just guess at the others or will you actually share?

Well the OP is not very clear. Apparently he has a setup that does not interact with the outside world (hence 'silent'), and now he wants the outside world to be able to cancel that setup.

If he is writing the MSI, he could create a CA that checks for a certain condition, like existence of a registry key. When the condition is met the CA generates an error and the installation stops. Now the outside world can cancel the install by creating the registry key. That CA should be included many times inside the execution sequence, so the time between the registry key creation and the actual cancelling is not too long.

If the MSI is already made, but he is making a boot strapper (Setup.exe) he should create his own UI, using MsiSetExternalUI. This UI has no visual elements (since OP wants a setup that is silent) but that should be able to stop the install.

If the MSI is already made, as well as the Setup.exe, he should use DLL injection. Using that technique he should intercept calls to MsiProcessMessage and return the usercancel value (I believe -1).

Then again, the OP is not very clear and probably wants something totally different. For instance, maybe he just wants to prevent a silent install.