c# - How to find if Windows Service is started manually or by OS? -
i have windows service started manually.
there restart time in service makes restart itself. exit giving >0
number os , in service -> recovery tab, have set service restart on first, second , subsequent failures.
environment.exit(1)
but how find out if service started manually or os?
you can take registry
:
hklm\system\currentcontrolset\services\yourservicename
registry key: start
(reg_dword)
values: 1 -> system 2 -> automatic 3 -> manual 4 -> disabled
you can do
new servicecontroller("yourservicename")
and p/invoke fun: http://peterkellyonline.blogspot.de/2011/04/configuring-windows-service.html
Comments
Post a Comment