{"id":378,"date":"2018-02-16T21:56:26","date_gmt":"2018-02-17T02:56:26","guid":{"rendered":"http:\/\/techref.camellarry.com\/?p=378"},"modified":"2018-02-16T21:56:26","modified_gmt":"2018-02-17T02:56:26","slug":"start-stop-query-service-in-vb-net","status":"publish","type":"post","link":"http:\/\/techref.camellarry.com\/?p=378","title":{"rendered":"Start\/Stop\/Query Service in VB.NET"},"content":{"rendered":"<p>Imports System.ServiceProcess<\/p>\n<p>Public Class Form1<\/p>\n<pre>Private Sub btnQueryBES_Click(sender As System.Object, e As System.EventArgs) Handles btnQueryBES.Click\r\n Dim txt As String = \"besclient\" &amp; SC(txtIPAddress.Text, \"besclient\", \"query\")\r\nEnd Sub<\/pre>\n<pre>Private Sub btnStartBES_Click(sender As System.Object, e As System.EventArgs) Handles btnStartBES.Click\r\n Dim txt As String = \"besclient\" &amp; SC(txtIPAddress.Text, \"besclient\", \"start\")\r\nEnd Sub<\/pre>\n<pre>Private Sub btnStopBES_Click(sender As System.Object, e As System.EventArgs) Handles btnStopBES.Click\r\n Dim txt As String = \"besclient\" &amp; SC(txtIPAddress.Text, \"besclient\", \"stop\")\r\nEnd Sub<\/pre>\n<pre>Function SC(MachineName As String, ServiceName As String, cmd As String) As String\r\n Dim txt As String = \"\"\r\n Dim TermService As New System.ServiceProcess.ServiceController(ServiceName, MachineName)\r\n\r\nSelect Case LCase(cmd)\r\n Case \"start\"\r\n TermService.Start()\r\n Case \"stop\"\r\n TermService.Stop()\r\n Case Else\r\n End Select\r\n\r\nSelect Case LCase(TermService.Status)\r\n Case \"1\"\r\n txt = \" stopped\"\r\n Case \"2\"\r\n txt = \" starting\"\r\n Case \"3\"\r\n txt = \" stop pending\"\r\n Case \"4\"\r\n txt = \" running\"\r\n Case Else\r\n txt = \" undetermined\"\r\n End Select\r\n\r\nReturn txt\r\n End Function<\/pre>\n<p>End Class<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Imports System.ServiceProcess Public Class Form1 Private Sub btnQueryBES_Click(sender As System.Object, e As System.EventArgs) Handles btnQueryBES.Click Dim txt As String = &#8220;besclient&#8221; &amp; SC(txtIPAddress.Text, &#8220;besclient&#8221;, &#8220;query&#8221;) End Sub Private Sub btnStartBES_Click(sender As System.Object, e As System.EventArgs) Handles btnStartBES.Click Dim txt As String = &#8220;besclient&#8221; &amp; SC(txtIPAddress.Text, &#8220;besclient&#8221;, &#8220;start&#8221;) End Sub Private Sub btnStopBES_Click(sender As System.Object, e [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[9],"tags":[29,45,77,78,80],"class_list":["post-378","post","type-post","status-publish","format-standard","hentry","category-vb-net","tag-example","tag-microsoft","tag-vb-net","tag-visualbasic","tag-windows"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9t3oE-66","_links":{"self":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=378"}],"version-history":[{"count":1,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/378\/revisions"}],"predecessor-version":[{"id":379,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=\/wp\/v2\/posts\/378\/revisions\/379"}],"wp:attachment":[{"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=378"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/techref.camellarry.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}