2
我已經做了簡單的腳本來啓動/重新啓動程序,但沒有做出確認重新啓動的決定,因爲無論我在set/p命令中寫入「deci」都是空的。批量設置/ p不工作
同樣是即使我不使用ENABLEDELAYEDEXPANSION只是%慈%
@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
命令ECHO Decision: !deci! .
輸出始終是Decision .
我有Windows 8.1 x64的
一旦你修正了set/p deci = R:'也使用'IF/i「!deci!」 EQU「y」'忽略大小寫 –