1

How can i display a form in my installshield sequence optional by evaluating the error code of a batchscript?

Denis
  • 107
  • 1
  • 13

1 Answers1

0

Windows Installer offers no direct way to do this. What you will have to do is create an MSI .dll custom action that runs the batch file, captures its error code, and stores it into a Windows Installer Property (e.g. using MsiSetProperty). Then you can edit the Events on the relevant Next button to conditionally go your selected optional panel. (Don't forget to edit the Back button events accordingly so that your wizard remains consistent.)

Michael Urman
  • 15,737
  • 2
  • 28
  • 44
  • Ok thats the way i try it. Can you give me a hint, how i can create a custom action which runs a batch file and stores the errorlevel? MSI .dll custom action doesn't work, because it only accepts dll files. – Denis Jul 28 '16 at 12:30
  • Right; you would have to find or create the DLL that interfaces between MSI and batch files. – Michael Urman Jul 28 '16 at 21:55
  • Sorry I'm not that deep into InstallShield. In the meantime I programmed a console application which i execute as a custom action. But how can i save the exit code in a property? There are only 9 settings and none of them makes sense for me. – Denis Jul 29 '16 at 07:14
  • You can't. The action needs access to the currently running install, which it gets in a [C++ DLL](https://www.simple-talk.com/dotnet/visual-studio/visual-studio-setup---projects-and-custom-actions/) as an MSIHANDLE, or in other action types in similar fashion, but not in exe actions. You could try [DTF](http://stackoverflow.com/q/17238298) for its `session` object, or (I can't recommend it as they often get blocked) a VBScript action might better match your capability set, and it can access the `Session` object. – Michael Urman Jul 29 '16 at 12:04
  • I got it with a C# DLL which works very well. I log the property and can see the right value ("False" and "True"). This variable should route to the right form by using the next button. The 2 events looks like: Event: New Dialog Argument: DestinationFolder Condition: RIGHT_JAVA_INSTALLED="True" Event: New Dialog Argument: JavaDownloadForm Condition: RIGHT_JAVA_INSTALLED="False" On my pc where java is installed it goes to the DestinationFolder which is right. But on another PC where it's not installed, it breaks the Setup and i don't know why? How do i approach this problem? – Denis Aug 01 '16 at 13:20
  • Assuming it's not a problem with the JavaDownloadForm dialog, which you could check by reversing your conditions and testing on your pc, it's probably a problem in the custom action implementation. If it's throwing an exception, details may show up in a verbose log. If not, this is rapidly veering into the territory for a new question. – Michael Urman Aug 01 '16 at 17:17