winforms - How to start /stop a windows service through a Windows Form application -


i wish start , stop windows service application via windows form application. ons tart of application wish start windows service, , on application exit wish stop service.

how can achieved?

you want use servicecontroller class.

initialize service name, , call start() , stop() methods.

using system.serviceprocess; servicecontroller sc = new servicecontroller("my service name"); if (sc.status == servicecontrollerstatus.stopped) {   sc.start(); } //etc.. 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -