1.

Solve : net use not going to EOF?

Answer»

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
Code: (batch) [Select]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.

Code: [Select]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

Code: [Select]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
exitYou don't need any labels or gotos, you can just do this

Code: [Select]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




Discussion

No Comment Found