I have made simple script to start/restart program, but decision to confirm restarting is not made, because 'deci' is empty whatever I write in set /p command.
The same is even when I not use ENABLEDELAYEDEXPANSION just with %deci%
@echo off
cls
ECHO Preparing to start
tasklist /FI "IMAGENAME eq n.exe" 2>NUL | find /I /N "n.exe">NUL
IF "%ERRORLEVEL%"=="0" (
SETLOCAL ENABLEDELAYEDEXPANSION
ECHO Programm is running
ECHO "Do you want to restart program (y\n)"
SET /p deci = R:
ECHO Decision: !deci! .
IF "!deci!" EQU "y" (
ECHO Restarting
taskkill /f /im "n.exe"
start nginx.exe
) ELSE (
ECHO Aborted, but program still running.
)
) ELSE (
ECHO Not running. Starting
start n.exe
)
PAUSE
Command ECHO Decision: !deci! .
in output always is Decision .
I have Windows 8.1 x64
SET /p deci = R:
^ This space is included in the variable name
So you end with a variable named !deci !
. Better use
SET /p "deci= R:"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With