{"id":36,"date":"2011-02-21T15:52:38","date_gmt":"2011-02-21T22:52:38","guid":{"rendered":"http:\/\/blog.gptnet.net\/?p=36"},"modified":"2012-12-27T08:01:54","modified_gmt":"2012-12-27T15:01:54","slug":"bat-script-service-status","status":"publish","type":"post","link":"https:\/\/blog.gptnet.net\/?p=36","title":{"rendered":".bat script service status"},"content":{"rendered":"<p>The following script demonstrates how to query NT Service Controller for service status. This script was used to check if the application (service) is running and if not install. msi package. Basic logging is also included.<br \/>\nYou might need to find out service name. To do so issue the following cmd command to list all services:<br \/>\n<strong>sc query<\/strong><br \/>\n<!--more--><br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<\/p>\n<pre lang=\"DOS\" line=\"1\">@echo ON\r\nREM Created: Dec 08, 2009\r\nREM Author: Naz Snidanko\r\nREM Descrp: Query service and install .msi\r\nSC QUERY Printelligence | FIND \"STATE\" > null\r\n\r\nif %errorlevel% EQU 0 goto Good1\r\nif %errorlevel% EQU 1 goto NotGood1\r\n\r\n:Good1\r\ngoto DoNe\r\n:NotGood1\r\necho %COMPUTERNAME% from %username% Deployment >> \\\\syslogserver\\XEROX\\log.txt\r\nmsiexec \/i \"\\\\zeus\\Support\\naz\\script\\xerox\\Xerox Print Environment Assessor.msi\"\r\necho Started %date% %time% >> \\\\syslogserver\\XEROX\\log.txt\r\n:DoNe<\/pre>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\nHope it helps!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The following script demonstrates how to query NT Service Controller for service status. This script was used to check if the application (service) is running and if not install. msi package. Basic logging is also included. You might need to &hellip; <a href=\"https:\/\/blog.gptnet.net\/?p=36\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,1],"tags":[8,9,10],"class_list":["post-36","post","type-post","status-publish","format-standard","hentry","category-bat","category-random-stuff","tag-bat-2","tag-bat-script","tag-service-query"],"_links":{"self":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/36","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=36"}],"version-history":[{"count":10,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions"}],"predecessor-version":[{"id":131,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=\/wp\/v2\/posts\/36\/revisions\/131"}],"wp:attachment":[{"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=36"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=36"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.gptnet.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=36"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}