我在写这个批处理脚本时遇到了这个小问题。问:如果批处理脚本中存在/如果不存在
:Delete_File
cls
title Delete File
echo Welcome to the Utility Delete File!
echo Type the name of the file you want to delete:
echo.
set /p var=
echo.
echo I'm checking the existance of the file...
ping 192.0.2.2 -n 1 -w 2000>nul
if EXIST %var% del %var%
if NOT EXIST %var% echo The file doesn't exist. Check for errors and try again.
ping 192.0.2.2 -n 1 -w 1500>nul
set /p answer=1 - Go to Menu _ 2 - Go to Exit
if %answer%==1 goto Menu
if %answer%==9 goto Exit
所以,问题是,当文件建立时,它被删除,但它显示在第12个字符串的消息。 我需要显示的文件被成功删除的消息!”重定向你的菜单......
echo The file was successfully deleted!
echo Redirecting you to the Menu...
ping 192.0.2.2 -n 1 -w 2000>nul
goto Menu
我对这个问题的语法错误感到抱歉,但我新。 感谢每一个响应我得到 费德里科
您的意思是第12行代码。下面的答案解决了你的问题,但想想你正在使用的逻辑,你可以自己解决它。翻转线。 – Squashman