문제

Here's a simple batch file I made up. Get user input to create a duplicate of every batch file with a different extension. It works, but I'm having problems with my help flag

If the user doesn't input anything, I want to display a message. But I get an error saying there is an issue with the goto method.

@ECHO off
REM Backup.bat, 10/10/2013, Josh Barber

cls
echo Choose an extension
Set /P var= Enter a file extension:

if %var% == "" goto help
copy H:\Lab5\*.bat H:\Lab5\*.%var% 

goto end

:help 

echo Please choose a file extension

:end 

echo Process complete

pause
도움이 되었습니까?

해결책

@ECHO off
REM Backup.bat, 10/10/2013, Josh Barber

cls
echo Choose an extension
Set /P var= Enter a file extension:

if "%var%" == "" goto help
copy H:\Lab5\*.bat H:\Lab5\*.%var% 

goto end

:help 

echo Please choose a file extension

goto :end
:end 

echo Process complete

pause

Use quotes or if defined var .When %var% has no value you are executing if == "" which has wrong syntax.

다른 팁

set /p var=" enter file extension: "
if (%var%) == () goto help
set /p name=" enter file extension: "
:help
echo "End of Program"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top