Launch exe after setup has finished

Fritz

Freshman
Joined
Oct 6, 2002
Messages
40
Location
switzerland
How can I launch the installed application or some html-file (Readme-file) after setup has finished?

Also would like to know if it's possible, to launch something after running dotnetfx.exe (framework install).

I have an app (vb.net2003) which is to be installed as shared on a network. So afterwards I need to install the framework on the client machines to be able to run the app from the network (server or computer which has the app declared as shared). I used to do it with another exe written in vb6, but now I want to simplify the installation for the users.
 
If you are using a windows installer project, you can add a "Custom Action" which will execute after installation. Just right click on the install project in the solution explorer, go to view --> custom actions. From there you can specify the executable as well as other options of when to run it. Generally, you would make a seperate project that will do all this fancy stuff and then have your custom actions of the installer project run it.
 
I've tried that already. As far as I could see, custom actions only do things during install, like installing additional components or call a Website. But I only can launch the app after it has been installed completely and setup has finished, else setup will be cut off.
Or do you know exactly, how to declare the CA, to launch to launch any kind of fancy stuff after? Could be another exe also. All help that I have been consulting up to now, and that was quite a lot, only indicates to CA to be executed during install.

Thank you anyway

Fritz
 
According to MSDN, a custom action can be executed at the very end of the installation, so in theory, your normal install will be complete. There is an article on msdn that talks about launching an html file after installation, and I assume that all you have to do is launch your executable instead.
Another option to consider is to add a registry key called FirstRun to your installer project and set its value to "true". So the very first thing your app should do upon launch is check this registry value and run your executable if it is "true". Make sure the key is set to "false" (or deleted) after running the exe so that it won't run anymore upon launch of your app.
 
So you say to create a registry key and check it first thing of the install. And run the executable if it's true.....But opposite to what the user wrote...How can I run an executable at the start of the setup before coping any files?
 
As I told you: I have tried that already, and it launches some file after the installation of the app, but this does not mean, that the setup has finished, as the custom action is part of the setup. It only installs the application first and then looks up for additional components to install. And after that, setup will terminate properly with a MsgBox: Setup was terminated successfully!

The article you mentioned also says: 'The installation does not fail if the custom action fails.' This means, setup has NOT finished by the time it calls the custom action.

About the other possibility, using a registry key called FirstRun, I confess, that I don't have the knowledge on how to do that. But as michelek says, you cannot run the exe before copying any files. Or could explain better?

Fritz
 
If the custom action fails, crashes, whatever, then your normal installation is unharmed. Setup does not fail if the custom action fails. Basically your installation is already completed aside from whatever your custom action is. So the only concern that I see you have is that your custom action might fail. Well make sure it doesn't fail then!

Here is what I mean about the other option:
When a user launches an app, the main form's load event is called. Within that event, I write a routine that checks the registry for the FirstRun key. If the value stored in that key = "true", then I know its the first time that a user has launched my application. In that case, I call a method to take care of some pre-requisites (such as launching another executable) and so forth. I make sure that the FirstRun is set to "false" at the end of this method so that it will not execute anymore upon future launch of the app. So basically, my app doesn't get into any real stuff until this has all been accomplished. Its a beat around the bush trick, and always worked great for me. You will have to modify your Install Project by adding a registry key called FirstRun, and set its value to "true". Right click on the root of your install project -> go to view -> select "Registry". Pick or create a place to put the key on the left and set its name and value on the right. If you haven't worked with the registry then there are tons of posts that can help you with that.

As for michelek's question, I'm not too keen on the pre-install stuff. I've read around on MSDN and saw some things about precedence order and what not, but I didn't get too deep into it. Supposively there's some initial event that happens at the beginning of an install and there is a way to capture this and run a custom action. You might want to check into it.
 
Thank you. I'm busy with other problems right now, but I will try your idea once more these days. I'll post the result again.

Fritz
 
Back
Top