Computer Hope
Microsoft => Microsoft DOS => Topic started by: metal_man77 on March 29, 2017, 10:18:01 AM
-
in an simple "IF" statement, I want, after the text, for it to GOTO :EOF.
This doesn't happens. it simply says : command completed successfully.
Here's the code
@echo off
if exist s:\1.txt (GOTO :exit
) else (
GOTO :net_use)
:net_use
net use s: \\que-mdt-01\fna_mdt\Logs
echo Do Not Delete >>s:\1.txt
GOTO :EOF
:exit
echo Path already exist. Exiting.
pause
exit
:EOF
pause
exit
-
Edited the if ... else block. Don't put stuff after the first or before the last parentheses. The ) else ( must all be on one line which you did right.
@echo off
if exist s:\1.txt (
GOTO :exit
) else (
GOTO :net_use
)
:net_use
net use s: \\que-mdt-01\fna_mdt\Logs
echo Do Not Delete >>s:\1.txt
GOTO :EOF
:exit
echo Path already exist. Exiting.
pause
exit
:EOF
pause
exit
Or you can do this
@echo off
if exist s:\1.txt (GOTO :exit) else (GOTO :net_use)
:net_use
net use s: \\que-mdt-01\fna_mdt\Logs
echo Do Not Delete >>s:\1.txt
GOTO :EOF
:exit
echo Path already exist. Exiting.
pause
exit
:EOF
pause
exit
-
You don't need any labels or gotos, you can just do this
@echo off
if exist s:\1.txt (
echo Path already exist. Exiting.
) else (
net use s: \\que-mdt-01\fna_mdt\Logs
echo Do Not Delete >>s:\1.txt
)
pause