Windows Service Application Restart

H

Hans Kesting

MikeZ explained :
How Can Windows Service Application Reatarts itself? Thanks.

Control Panel > Administrative Tools > Services
select your service
right-mouse > properties
"Recovery" tab

Hans Kesting
 
M

MikeZ

I mean that write code in windows service application to restart itself. It
does not include to restart service from second application or command line.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Do you realize the contradiction in your statement?
You want to write a code that stops itself and then restart again :)

Having said that, you can use an external process to do it. if your win
service spawn a process then this process can stop the service, do what you
need and restart the service.

You use ServiceControlManager for that.
 
M

MikeZ

For windows Application, it can restart itself by calling
ExitWindowsEx(EWX_REBOOT,0) (From User32.dll)

As you said, if the service cannot do the job by itself, an extra process is
the best choice.

Thanks.
 
W

Willy Denoyette [MVP]

MikeZ said:
For windows Application, it can restart itself by calling
ExitWindowsEx(EWX_REBOOT,0) (From User32.dll)

This does not restart an application, it restarts the system, you want to
restart the service, quite different isn't?
Restarting a Service is a feature that is OS version dependent, so what OS
are you running?

Willy.
 
M

MikeZ

Willy, I run Windows XP

Willy Denoyette said:
This does not restart an application, it restarts the system, you want to
restart the service, quite different isn't?
Restarting a Service is a feature that is OS version dependent, so what OS
are you running?

Willy.
 
C

christery

Try with nr 2 answer, put it in autorestart and just die... (the
service, not u) it will restart, but fixing problems that way is not
recommended..
//CY
 
R

Rudi

Hans said:
MikeZ explained :
Control Panel > Administrative Tools > Services
select your service
right-mouse > properties
"Recovery" tab
Hans Kesting

Is it possible to do this setting during install via batch (service
/install ?) and how? Thank you!

regards, Rudi
 

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

Top