Installer Auto Run

  • Thread starter Thread starter Thom Little
  • Start date Start date
T

Thom Little

I developed a C# application and a windows installer application that
properly installs the C# application on a new machine.

After the C# application is installed I would like to automatically start it
on the User's machine.

- How do I instruct the setup program to start execution of the newly
installed program?
- Is there a good general resource that documents the use of the installer?
 
Thom Little said:
I developed a C# application and a windows installer application that
properly installs the C# application on a new machine.

After the C# application is installed I would like to automatically start it
on the User's machine.

- How do I instruct the setup program to start execution of the newly
installed program?

Funnily enough, I'm after exactly the same thing at the moment. It's
easy enough to start the installed program - just use Process.Start
from a custom installation action. The tricky bit is getting it to only
start when the installer has finished - the custom action gets invoked
before the final dialog box is closed, and I can't see any way of
hooking into that very end bit...
- Is there a good general resource that documents the use of the installer?

I wish... it seems to be very limited in VS.NET. I assume this is a
limitation of VS.NET itself rather than MS Installer, as lots of other
install scripts seem to do much more than is possible frmo VS.NET.
Presumably that's where buying InstallShield comes in, but I'd rather
avoid that if possible...
 
just use Process.Start from a custom installation action.

How do I do that? (Please assume I am "dumb as dirt".)

For your question ... can't you just use a dialog box in the End section
prior to Finished that asks if the application should be run?
 
Thom Little said:
How do I do that? (Please assume I am "dumb as dirt".)

I use code like this:

// What directory is our assembly in
string ourDirectory = Path.GetDirectoryName
(Assembly.GetExecutingAssembly().Location);

Process.Start(ourDirectory+"\\Foo.exe");
For your question ... can't you just use a dialog box in the End section
prior to Finished that asks if the application should be run?

No - that happens after all the custom actions have already been run.
Besides, the idea (in my case) is to run the application after the
installer has absolutely finished - after the user has hit "Finish" on
the Finished dialog.

I've tried using the process ID of the custom installation action, and
getting the application to wait for that to finish, but it seems that
the action is executed in a different process to the main installation
itself.
 
I developed a C# application and a windows installer application that.....

At this moment I have the same problems.
It would be nice to have some default setup project that does following
things:

* Determin if there is a correct .NET framework installed.
* If not, then it redirects to the Windows update folder ready to scan the
computer and select the .NET framework installer. (I dont' like
redistributels since a Frenchmen would probably not like an English version
of .NET installed by default) .
* When the .NET is installed, then install the program.
* Finally register the strong key of the assembly automatically so that this
assembly have access to network drives.
* And start up the program when checked.

So the question is: does there exist a setup project that does this
somewhere?

I know I am lazy. ;-)
But this way I do not reinvent the wheel every time. :-)

Thanks.
 
Jon said:
I wish... it seems to be very limited in VS.NET. I assume this is a
limitation of VS.NET itself rather than MS Installer, as lots of other
install scripts seem to do much more than is possible frmo VS.NET.
Presumably that's where buying InstallShield comes in, but I'd rather
avoid that if possible...

Well, if simple installer is needed, NSIS 2.0 is a tool to look at -
free installation system, with simple script language,good GUI and such.

Only drawback is that it isn't MSI based.

For MSI there is some free tools to build MSIs but otherwise you have to
stick with commercial tools.
 
Jani Tiainen said:
Well, if simple installer is needed, NSIS 2.0 is a tool to look at -
free installation system, with simple script language,good GUI and such.

Only drawback is that it isn't MSI based.

Mmm... probably a no-no then, at the moment. (Fine for personal
projects though - must look at it some time.)
For MSI there is some free tools to build MSIs but otherwise you have to
stick with commercial tools.

Mmm. The annoying thing is that this is such a *common* thing to want
to do. Why on earth doesn't VS.NET support it? Loads of installers have
a "Start the application" or "View the release notes" or whatever at
the end. With VS.NET, you can't even ask the question at the end of the
installation, let alone actually run the thing when you want it to. :(

We're only actually running a *very* simple installation here - just
copy some files, add a shortcut, and optionally start the app. Nothing
that VS.NET can justifiably claim is "advanced".

(Where we *are* doing relatively advanced stuff is in terms of
installing stuff to a PocketPC, and there the situation is lamentably
worse. Anyone would think that wanting to ask the user some
configuration questions on the desktop and propagate those to the
device was something no-one has even considered before now. The state
of installation on PocketPC is absurd, IMO.)
 
I've tried using the process ID of the custom installation action, and
getting the application to wait for that to finish, but it seems that
the action is executed in a different process to the main installation
itself.

--
You might be able to find the parent process of the current process from
within your custom action and then use that ID to wait on. I haven't tried
it (and don't need it for my app); I'd be curious if you can get that to
work. You could also search through all running processes looking for MSI
processes (msiexec) and then wait on them all to terminate. If you're
installing a service then it's InstallUtil.exe that is running and invoking
your custom actions.
 
Mmm. The annoying thing is that this is such a *common* thing to want
to do. Why on earth doesn't VS.NET support it? Loads of installers have
a "Start the application" or "View the release notes" or whatever at
the end. With VS.NET, you can't even ask the question at the end of the
installation, let alone actually run the thing when you want it to. :(

You can ask the question at the beginning and save the answer to use later.
For "readme" files I use a custom action that is called during the commit
phase. The downside is that the action executes before the installer is
completely done, but the slight overlap is acceptable. It isn't perfect but
it works well enough for my purposes.

I agree that the install support in .net is weak. I've spent a lot of time
using ORCA to get customized behavior that is not supported in .net.
 
You might be able to find the parent process of the current process from
within your custom action and then use that ID to wait on. I haven't tried
it (and don't need it for my app); I'd be curious if you can get that to
work. You could also search through all running processes looking for MSI
processes (msiexec) and then wait on them all to terminate. If you're
installing a service then it's InstallUtil.exe that is running and invoking
your custom actions.

Unfortunately finding a parent process is easier said than done - it
would require P/Invoking undocumented methods, which might be different
for different operating systems. Horrible.

I've solved it in a pretty foul way in the end, but it works: the
installer will have the name of the product as its main window title. I
just search for any msiexec.exe processes with that main window title,
and wait for them to exit. Nasty, but it seems to work.

Cheers for your ideas though.
 
Dave said:
You can ask the question at the beginning and save the answer to use later.

Yes, but that's contrary to common installer usage, where it's the last
thing asked (on the very final dialog). It's just another annoyance.
For "readme" files I use a custom action that is called during the commit
phase. The downside is that the action executes before the installer is
completely done, but the slight overlap is acceptable. It isn't perfect but
it works well enough for my purposes.

In our case it just looks horrible, unfortunately. It's not a slight
overlap - it's however long the user waits before clicking "Close".
I agree that the install support in .net is weak. I've spent a lot of time
using ORCA to get customized behavior that is not supported in .net.

:(
 
Thanks for the lead.

I created a new class and successfully launched the application during the
install. The code ...

public class tlaSystemTrayLaunch
{
public static void Main( string[] args )
{
ProcessStartInfo psi = new ProcessStartInfo( );
psi.FileName = "tlaSystemTray.exe " ;
psi.WorkingDirectory = String.Join(" ",args );
Process.Start(psi );
}
}

How do I connect this class to a custom two-button dialog box?
 
Dave said:
later.

Yes, but that's contrary to common installer usage, where it's the last
thing asked (on the very final dialog). It's just another annoyance.


In our case it just looks horrible, unfortunately. It's not a slight
overlap - it's however long the user waits before clicking "Close".


:(

--

All agreed with... presumably all this stuff's possible using ORCA, but I
can't seem to justify spending time on stuff that's so seemingly trivial.
There are loads of MSI authoring tools out there but they all seem either a)
massively expensive or b) limited to what VS.NET can do or just slightly
more.

What might be nice is if some people that are good at MSI authoring got
together to make some kind of pluggable project so that actions like the
things you're looking for can be added as people need them - it seems to me
that the whole thing's basically like writing a database front end where you
could expect to slap on a new form and a bit of SQL for it to run. Maybe
there's even money to be made in them thar hills.

It's especially frustrating that Microsoft don't really seem to care about
what is one of the most important parts of any piece of software (at least
as far as an end user's concerned). There're some extremely simple things I
need to do but just don't have the time to learn how to do it.

Steve
 
Thom Little said:
Thanks for the lead.

I created a new class and successfully launched the application during the
install. The code ...

public class tlaSystemTrayLaunch
{
public static void Main( string[] args )
{
ProcessStartInfo psi = new ProcessStartInfo( );
psi.FileName = "tlaSystemTray.exe " ;
psi.WorkingDirectory = String.Join(" ",args );
Process.Start(psi );
}
}

How do I connect this class to a custom two-button dialog box?

Look up Custom Installation Actions in MSDN (or something similar -
fiddle around in the index until you find it!). Basically you need to
create a class library, and inside that add an Installer Component
where you put your code. Then in the Custom Actions part of the setup
project, you need to add hooks into your library.
 
I guess I was mumbling.

I tried to say that I already did everything that you suggested and it works
like a champ.

The question I have is how can I make the execution conditional based on a
standard two-button dialog? Put another way ... How do I connect a
two-button dialog to a custom class?

--
-- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd.
--

Jon Skeet said:
Thom Little said:
Thanks for the lead.

I created a new class and successfully launched the application during the
install. The code ...

public class tlaSystemTrayLaunch
{
public static void Main( string[] args )
{
ProcessStartInfo psi = new ProcessStartInfo( );
psi.FileName = "tlaSystemTray.exe " ;
psi.WorkingDirectory = String.Join(" ",args );
Process.Start(psi );
}
}

How do I connect this class to a custom two-button dialog box?

Look up Custom Installation Actions in MSDN (or something similar -
fiddle around in the index until you find it!). Basically you need to
create a class library, and inside that add an Installer Component
where you put your code. Then in the Custom Actions part of the setup
project, you need to add hooks into your library.
 
All agreed with... presumably all this stuff's possible using ORCA, but I
can't seem to justify spending time on stuff that's so seemingly trivial.
There are loads of MSI authoring tools out there but they all seem either a)
massively expensive or b) limited to what VS.NET can do or just slightly
more.

What might be nice is if some people that are good at MSI authoring got
together to make some kind of pluggable project so that actions like the
things you're looking for can be added as people need them - it seems to me
that the whole thing's basically like writing a database front end where you
could expect to slap on a new form and a bit of SQL for it to run. Maybe
there's even money to be made in them thar hills.

It's especially frustrating that Microsoft don't really seem to care about
what is one of the most important parts of any piece of software (at least
as far as an end user's concerned). There're some extremely simple things I
need to do but just don't have the time to learn how to do it.

Yup. To be honest, I'd be perfectly happy with a reference manual and a
big text file to edit, with a command line tool to build the whole lot
together into an MSI file. So long as the error messages are
intelligible and the documentation is good, I don't *need* wizards, and
frankly they end up making things harder a lot of the time.
 
Thom Little said:
I guess I was mumbling.

I tried to say that I already did everything that you suggested and it works
like a champ.

The question I have is how can I make the execution conditional based on a
standard two-button dialog? Put another way ... How do I connect a
two-button dialog to a custom class?

Oh, I see. Sorry.

I don't know about button dialogs, but for checkboxes at least, you set
the property name of the checkbox, and use the same name for the
condition of the action. I'll have a look into buttons, if you like.
 
I don't know about button dialogs, but for checkboxes at least, you set
the property name of the checkbox, and use the same name for the
condition of the action.

If you could point me at an example, this is probably all that I need.

I have not yet found an example that illustrates the connection between the
dialog boxes and the custom action that I have.

(My GUESS it that it is trivial and obvious after you see it once.)
 
Thom Little said:
If you could point me at an example, this is probably all that I need.

I have not yet found an example that illustrates the connection between the
dialog boxes and the custom action that I have.

(My GUESS it that it is trivial and obvious after you see it once.)

It's pretty simple. When you say "two button dialog" do you mean two
*radio* buttons?

If so, go to the property page for the dialog (where you set the text
etc) and set the ButtonProperty to, say, WHICH_OPTION_IS_SELECTED.

Then for the custom action, set the Condition property to something
like

WHICH_OPTION_IS_SELECTED="First value"

if you only want the action to fire if the first value was selected
(where "First value" here is the value of the radio button - keep the
quotes).
 
Maybe you'd find the Windows Installer XML (WiX) toolset useful:

http://sourceforge.net/projects/wix/

From the SourceForge page:

"The Windows Installer XML (WiX) is a toolset that builds Windows
installation packages from XML source code. The toolset supports a command
line environment that developers may integrate into their build processes to
build MSI and MSM setup packages."

This is a Microsoft released project that's been made available via
SourceForge; a blog detailing more information can be found here:
http://blogs.msdn.com/robmen/category/4625.aspx
 
Back
Top