How to: automatically remove LOCKFILE on server start (WINDOWS)

How to: automatically remove LOCKFILE on server start (WINDOWS)

Have you ever had that annoying issue when your server started up and the LOCKFILE still existed in the webMethods folder?
I’ve created a small script for windows which tackles this issue.
set jobname=softwareAGwebMethodsIntegrationServer_8.0
set location=C:SoftwareAGIntegrationServerLOCKFILE
for /F “tokens=3 delims=: ” %%H in (‘sc query “%jobname%” ^| findstr ”        STATE”‘) do (
  if /I “%%H” NEQ “RUNNING” (
                IF EXIST %location% GOTO REMOVEFILEANDSTART
  )
)
:REMOVEFILEANDSTART
del %location%
net start “%jobname%”
Variable jobname is your servicename which you set to start automatic
To find this name open Services and double click the job name
The name entered behind Service name is the name you need to enter for this variable.
Variable “location” is the location of the LOCKFILE, enter the full path.
Explanation of the code :
set jobname=softwareAGwebMethodsIntegrationServer_8.0
set location=C:SoftwareAGIntegrationServerLOCKFILE
Declaration of the variables.
for /F “tokens=3 delims=: ” %%H in (‘sc query “%jobname%” ^| findstr ”        STATE”‘) do (
  if /I “%%H” NEQ “RUNNING” (
                IF EXIST %location% GOTO REMOVEFILEANDSTART
  )
)
Loop over the result of sc query “%jobname%”  and search for the word STATE
If the result of STATE is different from RUNNING then execute function REMOVEFILEANDSTART
:REMOVEFILEANDSTART
del %location%
net start “%jobname%”
Delete the LOCKFILE and start the service.
To use this script, create a scheduled task which is triggered on server startup.
Author: Jeroen W.
No Comments

Post A Comment