How to reboot at end of deployment

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My deployment contains sevral projects, one of which is a service. The
installation does not automatically carry out a reboot at the end of the
installation process, which is required to start the service. Is there any
way I can put something into the deplyment project to make the target system
reboot at the end of the setup?
 
You will have to restort to WinApi and pinvoke.

There is an example in MSDN at :

ms-help://MS.MSDNQTR.2005APR.1033/sysinfo/base/how_to_shut_down_the_system.htm

Regards,
Tasos
 
Thanks Tasos, but your link didn't work. Perhaps I should have mentioned that
I am using VS2003.
 
My deployment contains sevral projects, one of which is a service. The
installation does not automatically carry out a reboot at the end of the
installation process, which is required to start the service. Is there any
way I can put something into the deplyment project to make the target system
reboot at the end of the setup?

Pop up a dialog that says "You need to reboot" :)

I would have the service start without the reboot.
 
Wow. But perhaps "Displaying the Shutdown Dialog Box" (two subjects lower) is
more user-friendly?
 
Thanks Michael and Piebald for both those references , however they are not
exactly easy to pop into my deployment project. I presume I have to write a
program to do it, and then call it as a Custom Action in the deployment
project, is that the idea?
 
Hello PIEBALD,

P> Wow. But perhaps "Displaying the Shutdown Dialog Box" (two subjects
P> lower) is more user-friendly?

Sure. Because user, not you decided when restart system :)

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
 
So would I. Do you know how to make the deployment project do that?

Well, I've never done it, I haven't fiddled with custom actions yet either.

But I _have_ written a service, which resides in an EXE which can take
command-line parameters to do such things. The code I have is pretty
convoluted, but look into:

System.ServiceProcess.ServiceController svc = new
System.ServiceProcess.ServiceController
(
"ServiceName"
) ;

if ( ( svc.Status != System.ServiceProcess.ServiceControllerStatus.Running )
&&
( svc.Status != System.ServiceProcess.ServiceControllerStatus.StartPending ) )
{
svc.Start() ;
svc.WaitForStatus (
System.ServiceProcess.ServiceControllerStatus.Running ) ;
}

You could probably write a simple program that simply does that and have the
custom action run it.
 
You don't need to force a reboot to start the service. You can use WMI
to start the service programmatically via a custom action.
 
Well, I'll try that. I was hoping Visual Studio might be a bit more helpful.
You don't have any more details do you?
 
Oh, it dosen't use WMI, I was mistaken about that part.

You'd put that code inside an installer class, which is part of your
appilcation assembly.

See InstallerBase for some details on that.

You then add a custom action; the custom action should be the primary
output of your application.
 
Ha. It is so easy when you know how. That article gave me the clue. Thanks.
Just override the Commit method in the Installer derived class, instantiate a
ServiceController with the name of the service and call Start(). Works like a
charm (which is more than can be said for these newsgroups - am I the only
one that has to click the "read the response" link 20 times before I get it?)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top