my bat file is located as follows
<app-root>\bin\myscript.bat
my text file containing the PID i am looking to extract is located here
<app-root>\log\pid.lock
@echo off
@REM declare the location of the PID file
set "PID_FILE=%~dp0..\log\pid.lock"
@REM the following works to read the PID
type "%PID_FILE%"
@REM but setting it to a variable does not work
if exist "%PID_FILE%" (
set /p PID=<"%PID_FILE%"
@REM this returns nothing ...
echo The PID is: %PID%
) else (
echo PID file not found: %PID_FILE%
)
the contents of my pid.lock file just contains a singular pid
8120
output:
PS C:\Users\ALilland\Documents\dev\app\bin> .\online.bat
8120The PID is:
how can i extract my PID to a variable?