How to restart FireDaemon Pro services remotely with SC

SC (sc.exe) is a built-in Windows utility that can be used to manage native Windows services as well as FireDaemon Pro services. You can create a batch script to restart FireDaemon Pro services. The script is below. Adjust it for your own use as you see fit! The script is designed to be synchronous (i.e. the script waits for the service to be fully shutdown before attempting to start it again):


:: Restart a FireDaemon Pro service remotely with SC
:: Create a text file called restart.cmd and copy / paste the contents of this script
:: To use the script:
::     restart.cmd <HostName> "<ServiceName>"
::
:: Where:
::    <HostName> is the name of the computer the service is running on
::    <ServiceName> is the short name of the FireDaemon Pro service enclosed in double quotes
::
@echo off
setlocal enabledelayedexpansion

echo Stopping Service \\%1\%2
sc \\%1 stop %2

:loop
set count=1
for /f "tokens=*" %%f IN ('sc query %2') do (
    set var!count!=%%f
    set /a count=!count!+1
)

echo %var3% | findstr /c:"STOPPED">nul && (
  echo Service \\%1\%2 is stopped
  goto end
) || (
  echo Waiting for Service \\%1\%2 to stop
  timeout 1 /nobreak >nul
  goto loop
)

:end
echo Starting Service \\%1\%2
sc \\%1 start %2

endlocal

How to restart FireDaemon Pro services remotely with PowerShell


You can complete the same in Powershell 7 using the following cmdlet. For more information see the Microsoft Powershell Get-Service and Microsoft PowerShell Restart-Service guides:


# Restart a FireDaemon Pro service remotely with PowerShell
# <Hostname> is the name of the computer the FireDaemon Pro service is running on
# <ServiceName> is the short name of the FireDaemon Pro service enclosed in single quotes
#
Get-Service -ComputerName <HostName> -Name '<ServiceName>' | Restart-Service