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.
blogger

blogger

Curious to know more about this topic?

Working at i8c

i8c is a system integrator that strives for an informal atmosphere between its employees, who have an average age of approx 30 years old. We invest a lot of effort in the professional development of each individual, through a direct connection between the consultants and the management (no multiple layers of middle management). We are based in Kontich, near Antwerp, but our customers are mainly located in the triangle Ghent-Antwerp-Brussels and belong to the top 500 companies in Belgium (Securex, Electrabel, UCB, etc…).

Quality Assurance

i8c is committed to delivering quality services and providing customer satisfaction. That’s why we invested in the introduction of a Quality Management System, which resulted in our ISO9001:2000 certification. This guarantees that we will meet your expectations, as a reliable, efficient and mature partner for your SOA & integration projects.

i8c - ISO9001-2015

Also worth reading

Integrating with TIBCO CLOUD

Our experts Glenn, Jason, Jurgen, and Kevin dedicated an i8c FastTrack Day to examining the TIBCO iPaaS offering. Check out their Research & Development day report to learn what they uncovered. 👇  TIBCO CLOUD™ The TIBCO Cloud™ Integration enterprise integration platform-as-a-service (iPaaS) provides self-service integration

Read More »

Meet our Integration Specialist – Alexandra

Alexandra worked in tech for 15 years before joining i8c. With lots of experience in API management and Java development, we’re thrilled to add yet another expert to our i8c community! It’s pretty clear why we want to work with Alexandra, so let’s take a

Read More »