<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>docs/content/features/windows-service.md - fork/static-web-server @ allow-symlink</title>
<meta name="description" content="docs/content/features/windows-service.md in fork/static-web-server at allow-symlink.">
<meta property="og:title" content="docs/content/features/windows-service.md - fork/static-web-server @ allow-symlink">
<meta property="og:description" content="docs/content/features/windows-service.md in fork/static-web-server at allow-symlink.">
<meta property="og:type" content="website">
<meta property="og:site_name" content="git.julia.blue">
<link rel="stylesheet" href="/css/style.css?v=62">
<script type="module" src="/js/main.js?v=62"></script>
</head>
<body>
<main data-ref="allow-symlink" data-tip="4414610fe1b0370ff0ac415e9367548840584710">
<noscript>
  <div class="callout">
    <p>
      hey! this is a static git repo viewer. commit diffs, file history,
      older commits and other revisions won't load without javascript.
    </p>
    <p>
      you are still able to view source files on branch/tag tips,
      but the experience is degraded.
    </p>
  </div>
</noscript>
<header class="repo"><div>
<h1>fork/static-web-server</h1>
</div>
<pre class="clone">git clone https://git.julia.blue/fork/static-web-server</pre>
</header>
<p class="snapshot-commit"><span class="commit-author">Matthias Schoettle</span><span class="commit-message" data-commit="dd43d06551fcf853e0012381c76af5b832d23b57">refactor: format check support Markdown files via mdformat (#597)</span><span class="snapshot-sha sha" data-commit="dd43d06551fcf853e0012381c76af5b832d23b57">dd43d06</span><time datetime="2025-12-07T04:40:21-05:00" title="2025-12-07 04:40:21 -0500">2025-12-07</time></p>
<header class="topbar"><details class="switcher"><summary>allow-symlink</summary><div class="menu"><strong>branches</strong><a class="current" href="/fork/static-web-server/ref/allow-symlink/">allow-symlink</a><a class="all" href="/fork/static-web-server/refs">all refs →</a></div></details><nav class="crumbs"><a href="/fork/static-web-server/">static-web-server</a> / <a href="/fork/static-web-server/ref/allow-symlink/tree/docs/">docs</a> / <a href="/fork/static-web-server/ref/allow-symlink/tree/docs/content/">content</a> / <a href="/fork/static-web-server/ref/allow-symlink/tree/docs/content/features/">features</a> / <span class="cur">windows-service.md</span></nav>
<span class="view-stats"><span>7.0 KiB</span><span>159 lines</span></span><span class="actions"><a class="raw" href="/fork/static-web-server/raw/ec87e9e6cca4e67c20e5140aafbf771b6fe80357/docs/content/features/windows-service.md">raw</a></span></header>
<div class="markdown-view"><input type="radio" name="markdown-view" id="markdown-rendered" checked><label for="markdown-rendered">rendered</label><input type="radio" name="markdown-view" id="markdown-code"><label for="markdown-code">code</label><section class="readme rendered"><h1>Windows Service</h1>
<p><strong><code>SWS</code></strong> can be also executed in a <a href="https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc783643(v=ws.10)">Windows Service</a> context. Therefore it also provides a subcommand to <em>install</em> SWS as a Windows Service.</p>
<p>This feature is disabled by default and can be controlled by the boolean <code>-s, --windows-service</code> option or the equivalent <a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/configuration/environment-variables.md#server_windows_service">SERVER_WINDOWS_SERVICE</a> env.</p>
<p><img src="https://user-images.githubusercontent.com/1700322/169807572-d62a7bab-b596-4597-85f7-31a7c02aeefe.png" alt="Static Web Server running as a Windows Service" /></p>
<blockquote>
<p><em>Static Web Server running as a Windows Service and displayed by 'services.msc' application.</em></p>
</blockquote>
<h2>Important Notes</h2>
<ul>
<li>This is an obvious Windows platform-specific feature.</li>
<li>The SWS Windows Service option (<code>windows-service</code>) doesn't create a Windows Service per se. It just tells SWS to run in a Windows Service context. So it's necessary to <a href="#install-the-service">install the SWS Windows Service</a> first.</li>
<li>Enabling the <code>windows-service</code> option via the <a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/configuration/config-file.md">configuration file</a> is unnecessary if you use the <a href="#install-the-service">install subcommand</a> to create the service since it already enables it during the service installation.</li>
<li>However, you can enable the <code>windows-service</code> option for example if you plan to create your own Windows Service and use SWS with it.</li>
</ul>
<h2>Service privileges</h2>
<p>To either install or uninstall the SWS Windows service requires <em>administrator</em> privileges, so make sure to open the terminal application as administrator or give your <a href="https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.2">Powershell</a> session enough privileges otherwise you will get an <code>"Access is denied"</code> error.</p>
<p>We recommend a Powershell session with administrator privileges.</p>
<h2>Windows Firewall</h2>
<p>You can serve content with SWS in a Windows network. However, if you face issues running SWS it could be due to missing firewall configuration. So you probably have to define an <code>inbound rule</code> to allow inbound network traffic on a specified TCP port of your choice.</p>
<p>Follow the steps below to adjust your firewall:</p>
<ol>
<li>Configure an <a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-firewall/create-an-inbound-port-rule">Inbound Port Rule</a> in your Windows firewall so clients can reach the server's port.</li>
<li>In your SWS config file, use the server IP as a host or a non-routable address like <code>0.0.0.0</code> if you prefer.</li>
<li>Create a Windows Service following https://static-web-server.net/features/windows-service/ and start it.</li>
<li>Finally, restart the service to apply the changes.</li>
</ol>
<p>Note that the steps above are general and you have to adjust your firewall rule(s) according to your needs.</p>
<h2>Install the service</h2>
<p>To install the SWS service use the <code>install</code> command along with a <a href="/fork/static-web-server/ref/allow-symlink/blob/docs/content/configuration/config-file.md">configuration file</a> for further SWS options customization.</p>
<p>Make sure to provide a configuration file to run SWS service properly. In particular, configure the server <code>address</code>, <code>port</code> and <code>root</code> directory accordingly.
If not then the service might not start.</p>
<p>The following command will create the SWS service called <code>static-web-server</code> with a "<code>Static Web Server</code>" display name.</p>
<pre class="language-powershell"><a-f>static-web-server.exe</a-f> -w C:\Users\MyUser\sws.toml install
<a-c># Windows Service (static-web-server) is installed successfully!</a-c>
<a-c># Start the service typing: sc.exe start &quot;static-web-server&quot; (it requires administrator privileges) or using the &#39;services.msc&#39; application.</a-c></pre>
<h2>Interact with the service</h2>
<p>SWS doesn't provide a way to interact with Windows services directly. Instead, use the Windows built-in tools to interact with the SWS service once created.</p>
<p>For that purpose, you can use either the Windows <a href="https://docs.microsoft.com/en-us/windows/win32/services/configuring-a-service-using-sc">sc.exe</a> or the <a href="https://docs.microsoft.com/en-us/windows/win32/services/services">services.msc</a> application.</p>
<p>For example, using <code>sc.exe</code> you can show the SWS service configuration used once installed.</p>
<pre class="language-powershell"><a-f>sc.exe</a-f> qc <a-s>&quot;static-web-server&quot;</a-s>
<a-c># [SC] QueryServiceConfig SUCCESS</a-c>

<a-c># SERVICE_NAME: static-web-server</a-c>
<a-c>#         TYPE               : 10  WIN32_OWN_PROCESS</a-c>
<a-c>#         START_TYPE         : 3   DEMAND_START</a-c>
<a-c>#         ERROR_CONTROL      : 1   NORMAL</a-c>
<a-c>#         BINARY_PATH_NAME   : C:\Users\MyUser\static-web-server.exe</a-c>
<a-c>#                                   --windows-service=true</a-c>
<a-c>#                                   --config-file=C:\Users\MyUser\sws.toml</a-c>
<a-c>#         LOAD_ORDER_GROUP   :</a-c>
<a-c>#         TAG                : 0</a-c>
<a-c>#         DISPLAY_NAME       : Static Web Server</a-c>
<a-c>#         DEPENDENCIES       :</a-c>
<a-c>#         SERVICE_START_NAME : LocalSystem</a-c></pre>
<p>Remember that alternatively, you can also use the <code>services.msc</code> application if you prefer GUI service control.</p>
<h3>Start</h3>
<p>To start the service use the following <code>sc.exe</code> command.</p>
<pre class="language-powershell"><a-f>sc.exe</a-f> start <a-s>&quot;static-web-server&quot;</a-s>
<a-c># SERVICE_NAME: static-web-server</a-c>
<a-c>#     TYPE               : 10  WIN32_OWN_PROCESS</a-c>
<a-c>#     STATE              : 2  START_PENDING</a-c>
<a-c>#                             (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)</a-c>
<a-c>#     WIN32_EXIT_CODE    : 0  (0x0)</a-c>
<a-c>#     SERVICE_EXIT_CODE  : 0  (0x0)</a-c>
<a-c>#     CHECKPOINT         : 0x0</a-c>
<a-c>#     WAIT_HINT          : 0x7d0</a-c>
<a-c>#     PID                : 3068</a-c>
<a-c>#     FLAGS              :</a-c></pre>
<h3>Status</h3>
<p>To show the service status use the following <code>sc.exe</code> command.</p>
<pre class="language-powershell"><a-f>sc.exe</a-f> query <a-s>&quot;static-web-server&quot;</a-s>
<a-c># SERVICE_NAME: static-web-server</a-c>
<a-c>#     TYPE               : 10  WIN32_OWN_PROCESS</a-c>
<a-c>#     STATE              : 4  RUNNING</a-c>
<a-c>#                             (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)</a-c>
<a-c>#     WIN32_EXIT_CODE    : 0  (0x0)</a-c>
<a-c>#     SERVICE_EXIT_CODE  : 0  (0x0)</a-c>
<a-c>#     CHECKPOINT         : 0x0</a-c>
<a-c>#     WAIT_HINT          : 0x0</a-c></pre>
<h3>Stop</h3>
<p>To stop the service use the following <code>sc.exe</code> command.</p>
<pre class="language-powershell"><a-f>sc.exe</a-f> stop <a-s>&quot;static-web-server&quot;</a-s>
<a-c># SERVICE_NAME: static-web-server</a-c>
<a-c>#         TYPE               : 10  WIN32_OWN_PROCESS</a-c>
<a-c>#         STATE              : 3  STOP_PENDING</a-c>
<a-c>#                                 (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)</a-c>
<a-c>#         WIN32_EXIT_CODE    : 0  (0x0)</a-c>
<a-c>#         SERVICE_EXIT_CODE  : 0  (0x0)</a-c>
<a-c>#         CHECKPOINT         : 0x2</a-c>
<a-c>#         WAIT_HINT          : 0xbb8</a-c></pre>
<p>After stopping the service you can also show its status.</p>
<pre class="language-powershell"><a-f>sc.exe</a-f> query <a-s>&quot;static-web-server&quot;</a-s>
<a-c># SERVICE_NAME: static-web-server</a-c>
<a-c>#         TYPE               : 10  WIN32_OWN_PROCESS</a-c>
<a-c>#         STATE              : 1  STOPPED</a-c>
<a-c>#         WIN32_EXIT_CODE    : 0  (0x0)</a-c>
<a-c>#         SERVICE_EXIT_CODE  : 0  (0x0)</a-c>
<a-c>#         CHECKPOINT         : 0x0</a-c>
<a-c>#         WAIT_HINT          : 0x0</a-c></pre>
<h2>Uninstall the service</h2>
<p>To uninstall the SWS service just use the <code>uninstall</code> command. Note that the service should be first stopped before uninstalling it.</p>
<pre class="language-powershell"><a-f>static-web-server.exe</a-f> uninstall
<a-c># Windows Service (static-web-server) is uninstalled!</a-c></pre>
<p>After uninstalling the service you can verify if removed.</p>
<pre class="language-powershell"><a-f>sc.exe</a-f> qc <a-s>&quot;static-web-server&quot;</a-s>
<a-c># [SC] OpenService FAILED 1060:</a-c>
<a-c>#</a-c>
<a-c># The specified service does not exist as an installed service.</a-c></pre>
</section><div class="code-panel"><pre class="code src language-markdown"><span class="code-line"><a class="ln" id="L1" href="#L1">1</a><span class="code-text"><a-p>#</a-p> <a-tt>Windows Service</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L2" href="#L2">2</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L3" href="#L3">3</a><span class="code-text">**`SWS`** can be also executed in a [Windows Service](&lt;https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc783643(v=ws.10)&gt;) context. Therefore it also provides a subcommand to *install* SWS as a Windows Service.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L4" href="#L4">4</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L5" href="#L5">5</a><span class="code-text">This feature is disabled by default and can be controlled by the boolean `-s, --windows-service` option or the equivalent [SERVER_WINDOWS_SERVICE](./../configuration/environment-variables.md#server_windows_service) env.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L6" href="#L6">6</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L7" href="#L7">7</a><span class="code-text">![Static Web Server running as a Windows Service](https://user-images.githubusercontent.com/1700322/169807572-d62a7bab-b596-4597-85f7-31a7c02aeefe.png)</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L8" href="#L8">8</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L9" href="#L9">9</a><span class="code-text"><a-p>&gt; </a-p>_Static Web Server running as a Windows Service and displayed by &#39;services.msc&#39; application._</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L10" href="#L10">10</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L11" href="#L11">11</a><span class="code-text"><a-p>##</a-p> <a-tt>Important Notes</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L12" href="#L12">12</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L13" href="#L13">13</a><span class="code-text"><a-p>- </a-p>This is an obvious Windows platform-specific feature.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L14" href="#L14">14</a><span class="code-text"><a-p>- </a-p>The SWS Windows Service option (`windows-service`) doesn&#39;t create a Windows Service per se. It just tells SWS to run in a Windows Service context. So it&#39;s necessary to [install the SWS Windows Service](#install-the-service) first.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L15" href="#L15">15</a><span class="code-text"><a-p>- </a-p>Enabling the `windows-service` option via the [configuration file](../configuration/config-file.md) is unnecessary if you use the [install subcommand](#install-the-service) to create the service since it already enables it during the service installation.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L16" href="#L16">16</a><span class="code-text"><a-p>- </a-p>However, you can enable the `windows-service` option for example if you plan to create your own Windows Service and use SWS with it.</span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L17" href="#L17">17</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L18" href="#L18">18</a><span class="code-text"><a-p>## </a-p><a-tt>Service privileges</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L19" href="#L19">19</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L20" href="#L20">20</a><span class="code-text"><a-p>To either install or uninstall the SWS Windows service requires *administrator* privileges, so make sure to open the terminal application as administrator or give your [Powershell](https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.2) session enough privileges otherwise you will get an `&quot;Access is denied&quot;` error.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L21" href="#L21">21</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L22" href="#L22">22</a><span class="code-text"><a-p>We recommend a Powershell session with administrator privileges.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L23" href="#L23">23</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L24" href="#L24">24</a><span class="code-text"><a-p>## </a-p><a-tt>Windows Firewall</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L25" href="#L25">25</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L26" href="#L26">26</a><span class="code-text"><a-p>You can serve content with SWS in a Windows network. However, if you face issues running SWS it could be due to missing firewall configuration. So you probably have to define an `inbound rule` to allow inbound network traffic on a specified TCP port of your choice.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L27" href="#L27">27</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L28" href="#L28">28</a><span class="code-text"><a-p>Follow the steps below to adjust your firewall:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L29" href="#L29">29</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L30" href="#L30">30</a><span class="code-text"><a-p>1. Configure an [Inbound Port Rule](https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-firewall/create-an-inbound-port-rule) in your Windows firewall so clients can reach the server&#39;s port.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L31" href="#L31">31</a><span class="code-text"><a-p>2. In your SWS config file, use the server IP as a host or a non-routable address like `0.0.0.0` if you prefer.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L32" href="#L32">32</a><span class="code-text"><a-p>3. Create a Windows Service following https://static-web-server.net/features/windows-service/ and start it.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L33" href="#L33">33</a><span class="code-text"><a-p>4. Finally, restart the service to apply the changes.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L34" href="#L34">34</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L35" href="#L35">35</a><span class="code-text"><a-p>Note that the steps above are general and you have to adjust your firewall rule(s) according to your needs.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L36" href="#L36">36</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L37" href="#L37">37</a><span class="code-text"><a-p>## </a-p><a-tt>Install the service</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L38" href="#L38">38</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L39" href="#L39">39</a><span class="code-text"><a-p>To install the SWS service use the `install` command along with a [configuration file](../configuration/config-file.md) for further SWS options customization.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L40" href="#L40">40</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L41" href="#L41">41</a><span class="code-text"><a-p>Make sure to provide a configuration file to run SWS service properly. In particular, configure the server `address`, `port` and `root` directory accordingly.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L42" href="#L42">42</a><span class="code-text"><a-p>If not then the service might not start.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L43" href="#L43">43</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L44" href="#L44">44</a><span class="code-text"><a-p>The following command will create the SWS service called `static-web-server` with a &quot;`Static Web Server`&quot; display name.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L45" href="#L45">45</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L46" href="#L46">46</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L47" href="#L47">47</a><span class="code-text"><a-p>static-web-server.exe -w C:\Users\MyUser\sws.toml install</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L48" href="#L48">48</a><span class="code-text"><a-p># Windows Service (static-web-server) is installed successfully!</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L49" href="#L49">49</a><span class="code-text"><a-p># Start the service typing: sc.exe start &quot;static-web-server&quot; (it requires administrator privileges) or using the &#39;services.msc&#39; application.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L50" href="#L50">50</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L51" href="#L51">51</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L52" href="#L52">52</a><span class="code-text"><a-p>## </a-p><a-tt>Interact with the service</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L53" href="#L53">53</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L54" href="#L54">54</a><span class="code-text"><a-p>SWS doesn&#39;t provide a way to interact with Windows services directly. Instead, use the Windows built-in tools to interact with the SWS service once created.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L55" href="#L55">55</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L56" href="#L56">56</a><span class="code-text"><a-p>For that purpose, you can use either the Windows [sc.exe](https://docs.microsoft.com/en-us/windows/win32/services/configuring-a-service-using-sc) or the [services.msc](https://docs.microsoft.com/en-us/windows/win32/services/services) application.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L57" href="#L57">57</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L58" href="#L58">58</a><span class="code-text"><a-p>For example, using `sc.exe` you can show the SWS service configuration used once installed.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L59" href="#L59">59</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L60" href="#L60">60</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L61" href="#L61">61</a><span class="code-text"><a-p>sc.exe qc </a-p><a-s>&quot;static-web-server&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L62" href="#L62">62</a><span class="code-text"><a-p># [SC] QueryServiceConfig SUCCESS</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L63" href="#L63">63</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L64" href="#L64">64</a><span class="code-text"><a-p># SERVICE_NAME: static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L65" href="#L65">65</a><span class="code-text"><a-p>#         TYPE               : 10  WIN32_OWN_PROCESS</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L66" href="#L66">66</a><span class="code-text"><a-p>#         START_TYPE         : 3   DEMAND_START</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L67" href="#L67">67</a><span class="code-text"><a-p>#         ERROR_CONTROL      : 1   NORMAL</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L68" href="#L68">68</a><span class="code-text"><a-p>#         BINARY_PATH_NAME   : C:\Users\MyUser\static-web-server.exe</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L69" href="#L69">69</a><span class="code-text"><a-p>#                                   --windows-service=true</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L70" href="#L70">70</a><span class="code-text"><a-p>#                                   --config-file=C:\Users\MyUser\sws.toml</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L71" href="#L71">71</a><span class="code-text"><a-p>#         LOAD_ORDER_GROUP   :</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L72" href="#L72">72</a><span class="code-text"><a-p>#         TAG                : 0</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L73" href="#L73">73</a><span class="code-text"><a-p>#         DISPLAY_NAME       : Static Web Server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L74" href="#L74">74</a><span class="code-text"><a-p>#         DEPENDENCIES       :</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L75" href="#L75">75</a><span class="code-text"><a-p>#         SERVICE_START_NAME : LocalSystem</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L76" href="#L76">76</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L77" href="#L77">77</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L78" href="#L78">78</a><span class="code-text"><a-p>Remember that alternatively, you can also use the `services.msc` application if you prefer GUI service control.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L79" href="#L79">79</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L80" href="#L80">80</a><span class="code-text"><a-p>### </a-p><a-tt>Start</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L81" href="#L81">81</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L82" href="#L82">82</a><span class="code-text"><a-p>To start the service use the following `sc.exe` command.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L83" href="#L83">83</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L84" href="#L84">84</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L85" href="#L85">85</a><span class="code-text"><a-p>sc.exe start </a-p><a-s>&quot;static-web-server&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L86" href="#L86">86</a><span class="code-text"><a-p># SERVICE_NAME: static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L87" href="#L87">87</a><span class="code-text"><a-p>#     TYPE               : 10  WIN32_OWN_PROCESS</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L88" href="#L88">88</a><span class="code-text"><a-p>#     STATE              : 2  START_PENDING</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L89" href="#L89">89</a><span class="code-text"><a-p>#                             (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L90" href="#L90">90</a><span class="code-text"><a-p>#     WIN32_EXIT_CODE    : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L91" href="#L91">91</a><span class="code-text"><a-p>#     SERVICE_EXIT_CODE  : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L92" href="#L92">92</a><span class="code-text"><a-p>#     CHECKPOINT         : 0x0</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L93" href="#L93">93</a><span class="code-text"><a-p>#     WAIT_HINT          : 0x7d0</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L94" href="#L94">94</a><span class="code-text"><a-p>#     PID                : 3068</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L95" href="#L95">95</a><span class="code-text"><a-p>#     FLAGS              :</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L96" href="#L96">96</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L97" href="#L97">97</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L98" href="#L98">98</a><span class="code-text"><a-p>### </a-p><a-tt>Status</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L99" href="#L99">99</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L100" href="#L100">100</a><span class="code-text"><a-p>To show the service status use the following `sc.exe` command.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L101" href="#L101">101</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L102" href="#L102">102</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L103" href="#L103">103</a><span class="code-text"><a-p>sc.exe query </a-p><a-s>&quot;static-web-server&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L104" href="#L104">104</a><span class="code-text"><a-p># SERVICE_NAME: static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L105" href="#L105">105</a><span class="code-text"><a-p>#     TYPE               : 10  WIN32_OWN_PROCESS</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L106" href="#L106">106</a><span class="code-text"><a-p>#     STATE              : 4  RUNNING</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L107" href="#L107">107</a><span class="code-text"><a-p>#                             (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L108" href="#L108">108</a><span class="code-text"><a-p>#     WIN32_EXIT_CODE    : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L109" href="#L109">109</a><span class="code-text"><a-p>#     SERVICE_EXIT_CODE  : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L110" href="#L110">110</a><span class="code-text"><a-p>#     CHECKPOINT         : 0x0</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L111" href="#L111">111</a><span class="code-text"><a-p>#     WAIT_HINT          : 0x0</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L112" href="#L112">112</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L113" href="#L113">113</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L114" href="#L114">114</a><span class="code-text"><a-p>### </a-p><a-tt>Stop</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L115" href="#L115">115</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L116" href="#L116">116</a><span class="code-text"><a-p>To stop the service use the following `sc.exe` command.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L117" href="#L117">117</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L118" href="#L118">118</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L119" href="#L119">119</a><span class="code-text"><a-p>sc.exe stop </a-p><a-s>&quot;static-web-server&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L120" href="#L120">120</a><span class="code-text"><a-p># SERVICE_NAME: static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L121" href="#L121">121</a><span class="code-text"><a-p>#         TYPE               : 10  WIN32_OWN_PROCESS</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L122" href="#L122">122</a><span class="code-text"><a-p>#         STATE              : 3  STOP_PENDING</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L123" href="#L123">123</a><span class="code-text"><a-p>#                                 (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L124" href="#L124">124</a><span class="code-text"><a-p>#         WIN32_EXIT_CODE    : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L125" href="#L125">125</a><span class="code-text"><a-p>#         SERVICE_EXIT_CODE  : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L126" href="#L126">126</a><span class="code-text"><a-p>#         CHECKPOINT         : 0x2</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L127" href="#L127">127</a><span class="code-text"><a-p>#         WAIT_HINT          : 0xbb8</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L128" href="#L128">128</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L129" href="#L129">129</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L130" href="#L130">130</a><span class="code-text"><a-p>After stopping the service you can also show its status.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L131" href="#L131">131</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L132" href="#L132">132</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L133" href="#L133">133</a><span class="code-text"><a-p>sc.exe query </a-p><a-s>&quot;static-web-server&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L134" href="#L134">134</a><span class="code-text"><a-p># SERVICE_NAME: static-web-server</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L135" href="#L135">135</a><span class="code-text"><a-p>#         TYPE               : 10  WIN32_OWN_PROCESS</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L136" href="#L136">136</a><span class="code-text"><a-p>#         STATE              : 1  STOPPED</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L137" href="#L137">137</a><span class="code-text"><a-p>#         WIN32_EXIT_CODE    : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L138" href="#L138">138</a><span class="code-text"><a-p>#         SERVICE_EXIT_CODE  : 0  (0x0)</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L139" href="#L139">139</a><span class="code-text"><a-p>#         CHECKPOINT         : 0x0</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L140" href="#L140">140</a><span class="code-text"><a-p>#         WAIT_HINT          : 0x0</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L141" href="#L141">141</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L142" href="#L142">142</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L143" href="#L143">143</a><span class="code-text"><a-p>## </a-p><a-tt>Uninstall the service</a-tt></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L144" href="#L144">144</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L145" href="#L145">145</a><span class="code-text"><a-p>To uninstall the SWS service just use the `uninstall` command. Note that the service should be first stopped before uninstalling it.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L146" href="#L146">146</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L147" href="#L147">147</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L148" href="#L148">148</a><span class="code-text"><a-p>static-web-server.exe uninstall</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L149" href="#L149">149</a><span class="code-text"><a-p># Windows Service (static-web-server) is uninstalled!</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L150" href="#L150">150</a><span class="code-text"><a-p>```</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L151" href="#L151">151</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L152" href="#L152">152</a><span class="code-text"><a-p>After uninstalling the service you can verify if removed.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L153" href="#L153">153</a><span class="code-text"></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L154" href="#L154">154</a><span class="code-text"><a-p>```</a-p><a-tl>powershell</a-tl></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L155" href="#L155">155</a><span class="code-text"><a-p>sc.exe qc </a-p><a-s>&quot;static-web-server&quot;</a-s></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L156" href="#L156">156</a><span class="code-text"><a-p># [SC] OpenService FAILED 1060:</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L157" href="#L157">157</a><span class="code-text"><a-p>#</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L158" href="#L158">158</a><span class="code-text"><a-p># The specified service does not exist as an installed service.</a-p></span><span class="code-break">
</span></span><span class="code-line"><a class="ln" id="L159" href="#L159">159</a><span class="code-text"><a-p>```</a-p></span></span></pre></div></div>
</main>
</body>
</html>
