Home > Software engineering >  Batch Script throwing error for missing txt file with sc command
Batch Script throwing error for missing txt file with sc command

Time:09-23

I have this batch script which is used to START/STOP/QUERY service status of windows services on remote servers. Assuming the batch script name is service_check.bat, the script is called as service_check.bat settings.txt QUERY/START/STOP, (obviously just one of either of those three). This script generates a table report after the process is complete. The issue is that it works fine when we call the service with QUERY option, but fails with START or STOP. The settings file reads as 192.168.1.200 "AxInstSV". Please suggest where I am going wrong with this.

'''
REM @Echo OFF
SETLOCAL enabledelayedexpansion

:: Clear the screen
CLS

:: Assign input to variables
SET settingsFile=%~1
SET inputOperationMode=%~2

for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') 
do set "dt=%%a"
set "YY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "hr=%dt:~8,2%"
set "mn=%dt:~10,2%"
set "today_date_time=%YY%_%MM%_           
  • Related