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

Prevent installing application from .msi file


8 replies to this topic

sumit_pyk

sumit_pyk
  • Full Members
  • 6 posts

Posted 21 October 2009 - 08:25

Aim : Prevent installing application from .msi file - force to run from .exe file

Description:

I'm have a deployment project in C++. After building installation files successfully, I have two files in my output folder (setup.exe and myfile.msi). As default, when user double click on any file in the two files, they can install my software normally. But now, I want to prevent user install my software from the .msi file. If they double click on .msi file, we can show the message to ask them run the setup.exe file instead, or do nothing (like Visual Studio 2003 did). I want to let user to install my software from setup.exe file only.

If you have any solution, please help me to solve this problem!
Thank you in advance.




smc0862

smc0862
  • Full Members
  • 54 posts

Posted 21 October 2009 - 09:59

You should be able to build your installer so that all the installation files are packaged into the SETUP.EXE. If you are using InstallShield to build your installation, then use the Release Wizard and set the option on the Release Configuration panel to compress all files into one Setup.

-Shawn



sumit_pyk

sumit_pyk
  • Full Members
  • 6 posts

Posted 21 October 2009 - 12:47

Hi Shawn,

Thanks for the reply,

Actually in our project we do not use the setup.exe generated by Installshield.
We have our own setup.exe and custom action dll. And from our setup.exe we call the .msi file.

I am in search of Visual Studio 2003 like solution . (i.e displaying a message box whenever .msi file is double clicked. )
Do you have any idea about how it can be done.

Thanks,
Sumit


smc0862

smc0862
  • Full Members
  • 54 posts

Posted 21 October 2009 - 15:09

Sumit,

That's a challenging one. Basically what you would need to do is bypass Window's functionality of opening an application based on the file association that is listed in the registry. How you could do that just for your application and not impact other .msi files, I'm not sure.

One other suggestion would be to create a self-extracting archive containing all your setup files using a tool like ZipGenius and set the options to unpack without prompting and to execute your setup.exe once the files are extracted. I use this method all the time and it works fine.

-Shawn

smc0862

smc0862
  • Full Members
  • 54 posts

Posted 21 October 2009 - 15:19

Another possible solution they way you would like it...

Within your MSI package create a dialog box that is conditionalized based on a defined property (i.e. LAUNCHED_BY_SETUP). Place the dialog in your UI sequence with the condition:

NOT LAUNCHED_BY_SETUP

Then in your SETUP.EXE when you launch the .MSI file add the property LAUNCH_BY_SETUP=1 to the command line.


So when the MSI is launched by someone by douple clicking on the MSI file, the property will not be defined, thus forcing the dialog to appear. Simply build this dialog with your message stating that they need to run SETUP.EXE and include just an OK button. On the OK button action just exit the installer.

When launched by the SETUP.EXE, you will pass this property into the MSI package on the command lne and thus bypassing the dialog box.

Hope this helps...

-Shawn

Edited by smc0862, 21 October 2009 - 15:20.


Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 22 October 2009 - 08:07

That's the way I would do it. However instead of building a custom dialog, use a custom action type 19 (display error message and abort) conditioned with the property. Users could still override your check by manually setting the property on the command line, but it would prevent the .msi double click.

However I wonder why you want to prevent instalaltion from the ,msi file? This is what system administrators will use when rolling out your package in an enterprise environment.
Also note that you would have to insert above mentioned custom action in both, the UI and the Execute sequence, because the UI sequence is skipped in a silent install.

smc0862

smc0862
  • Full Members
  • 54 posts

Posted 22 October 2009 - 10:47

QUOTE (Stefan Krueger @ 2009-10-22 08:07)
However instead of building a custom dialog, use a custom action type 19 (display error message and abort) conditioned with the property.

With all the years I have used InstallShield and custom actions I have never noticed the 'New Error' custom action in the IDE. It's always good to learn something new each day, regardless how trivial it may seem. blink.gif

-Shawn

sumit_pyk

sumit_pyk
  • Full Members
  • 6 posts

Posted 22 October 2009 - 13:36

Hi Shawn,

Thanks a lot .The solution suggested by you worked. smile.gif

Now I have another problem.

When I click on the “Ok” button of the dialog box, it takes me to the “Installshield wizard completed” dialog. This dialog contains following message.
“The wizard was interrupted before project test could be completely installed” … etc etc
And “Click finish to exit the wizard.”

However I want to exit from the installation when “Ok” button is clicked. I do not want the control should go to “Installshield wizard completed” dialog.

Would you please help me out.

Thanks,
Sumit


smc0862

smc0862
  • Full Members
  • 54 posts

Posted 22 October 2009 - 17:28

How adventurous do you feel? smile.gif

I don't think that you can stop the 'Interupted' dialog from appearing. This is MSI way of shutting down when you cancel the setup process.

I tried the following but I wouldn't call it best practice.


1.) I created an InstallScript function called myAbort and simply added the command:

function myAbort(hMSI)
begin
abort;
end;

2.) I then created an InstallScript custom action called myAbort and referenced the myAbort function I created in the first step.

3.) I inserted the custom action in the UI Sequence prior to when the Welcome panel would appear with the condition NOT LAUNCHED_BY_SETUP

The result of this is that when the installer runs by clicking the MSI file, it will go right to the 'Interupted' wizard panel. Now here's the adventurous part.

Using the Dialog editor, modify the SetupInterupted dialog. Go to the Behavior section for the dialog. For each item on the dialog in the 'white' area you can control whether or not they are visible using the 'Conditions' tab. For the existing items add the LAUNCHED_BY_SETUP property at the beginning of each condition like this:

LAUNCHED_BY_SETUP And NOT UpdateStarted

When your users launch using your setup program things should appear normal. If the launch using the MSI file, the 'Interrupted' white area of the dialog should look blank.

The final step is to add in your own label controls into the white area of the dialog and set the conditions for your labels Hide/Show based on the LAUNCHED_BY_SETUP property.


-Shawn