lundi 11 février 2019

If statement in batch script isn't working?

I have a batch script which when given the input "edit", should then echo "hello" as a sort of debug and open the batch scripts file in notepad. However for some inexplicable reason the script will not respond to the if statement no matter what. How do I get it to respond to the "edit" input?

REM @ECHO OFF
cd/
cd projects\py_test
ECHO Use this batch script to lauch Python modules living in "C:\Projects\py_test\" ONLY.
ECHO.
SET /P name="Type file name with file extension .py to start or type EDIT to edit this .bat: "
REM @ECHO OFF
cmd /k IF %name%==edit GOTO EDIT
REM IF EXIST %name% py %name%
REM IF NOT EXIST %name% echo  [101mERROR: The requested file could not be found.  Make sure the file exists in "C:\Projects\py_test\" and that the filename includes the ".py" extension.[0m 
@ECHO OFF
:EDIT
ECHO HELLO
REM notepad projects-py_test-dot_start.bat`

Aucun commentaire:

Enregistrer un commentaire