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

Python __call__ special method practical example -

How can I edit my VIM config so that Vim treats ".ejs" files the same as it currently treats my html files? -