.net - check if windows service exists and is running -


how can add condition code below check if services running?

for each s servicecontroller in servicecontroller.getservices()     if s.servicename = "test" or s.servicename = "test1" or s.servicename = "test2"         s.stop()     end if next 

you can check status of servicecontroller , stop if running. should check can stopped:

for each s servicecontroller in servicecontroller.getservices()     if s.servicename = "test" orelse         s.servicename = "test1" orelse         s.servicename = "test2"         if s.canstop andalso s.status = servicecontrollerstatus.running             s.stop()         end if     end if next 

note should use orelse , andalso whenever possible make code more efficient


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

javascript - Which segment of a polyline was clicked? -

c# - Avoiding duplicate methods for Task and Task<T> -