<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Start Splunk using batch file in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Start-Splunk-using-batch-file/m-p/329239#M61071</link>
    <description>&lt;P&gt;You can use Windows Service Configuration Manager to do this. Following seems to be a working script based off one of the answers on Stack Overflow &lt;CODE&gt;&lt;A href="https://stackoverflow.com/questions/3325081/how-to-check-if-a-service-is-running-via-batch-file-and-start-it-if-it-is-not-r" target="test_blank"&gt;https://stackoverflow.com/questions/3325081/how-to-check-if-a-service-is-running-via-batch-file-and-start-it-if-it-is-not-r&lt;/A&gt;&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;@Echo Off
set path="%WINDIR%\system32"
set ServiceName=splunkd

sc queryex "%ServiceName%"|Find "STATE"|Find /v "RUNNING"&amp;gt;Nul&amp;amp;&amp;amp;(
    echo %ServiceName% not running 
    echo Start %ServiceName%

    Net start "%ServiceName%"&amp;gt;nul||(
        Echo "%ServiceName%" did not start 
        exit /b 1
    )
    echo "%ServiceName%" started
    exit /b 0
)||(
    echo "%ServiceName%" Running
    exit /b 0
)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm. PS: I have set the &lt;CODE&gt;path&lt;/CODE&gt; to Windows system32 folder since the same is required to run &lt;CODE&gt;sc&lt;/CODE&gt; and &lt;CODE&gt;net start&lt;/CODE&gt; commands.&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2017 14:36:45 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-09-11T14:36:45Z</dc:date>
    <item>
      <title>Start Splunk using batch file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Start-Splunk-using-batch-file/m-p/329238#M61070</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;
I want splunk start using batch script ,when splunk is stopped..&lt;BR /&gt;
I tried like this ..&lt;BR /&gt;
when splunk status is stopped it will autometically run batch file to splunk start..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;set PATH=C:\Program Files\Splunk\bin\splunk status
ECHO %PATH% 
PAUSE
if  %PATH% == splunk is stopped (
   change it
restart splunk
)  
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Sep 2017 13:06:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Start-Splunk-using-batch-file/m-p/329238#M61070</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2017-09-11T13:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Start Splunk using batch file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Start-Splunk-using-batch-file/m-p/329239#M61071</link>
      <description>&lt;P&gt;You can use Windows Service Configuration Manager to do this. Following seems to be a working script based off one of the answers on Stack Overflow &lt;CODE&gt;&lt;A href="https://stackoverflow.com/questions/3325081/how-to-check-if-a-service-is-running-via-batch-file-and-start-it-if-it-is-not-r" target="test_blank"&gt;https://stackoverflow.com/questions/3325081/how-to-check-if-a-service-is-running-via-batch-file-and-start-it-if-it-is-not-r&lt;/A&gt;&lt;/CODE&gt; &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;@Echo Off
set path="%WINDIR%\system32"
set ServiceName=splunkd

sc queryex "%ServiceName%"|Find "STATE"|Find /v "RUNNING"&amp;gt;Nul&amp;amp;&amp;amp;(
    echo %ServiceName% not running 
    echo Start %ServiceName%

    Net start "%ServiceName%"&amp;gt;nul||(
        Echo "%ServiceName%" did not start 
        exit /b 1
    )
    echo "%ServiceName%" started
    exit /b 0
)||(
    echo "%ServiceName%" Running
    exit /b 0
)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try out and confirm. PS: I have set the &lt;CODE&gt;path&lt;/CODE&gt; to Windows system32 folder since the same is required to run &lt;CODE&gt;sc&lt;/CODE&gt; and &lt;CODE&gt;net start&lt;/CODE&gt; commands.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2017 14:36:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Start-Splunk-using-batch-file/m-p/329239#M61071</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-09-11T14:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Start Splunk using batch file</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Start-Splunk-using-batch-file/m-p/329240#M61072</link>
      <description>&lt;P&gt;thanks for your efforts..&lt;BR /&gt;
This is my answer&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;set root=C:\Program Files\SplunkUniversalForwarder\bin
cd/
cd  %root% 
splunk start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;finally i got but i dont know where can i store batch file in splunk.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2017 10:20:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Start-Splunk-using-batch-file/m-p/329240#M61072</guid>
      <dc:creator>harishalipaka</dc:creator>
      <dc:date>2017-09-13T10:20:49Z</dc:date>
    </item>
  </channel>
</rss>

