Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: net use not going to EOF  (Read 3159 times)

0 Members and 1 Guest are viewing this topic.

metal_man77

    Topic Starter


    Rookie
    • Yes
  • Computer: Specs
  • Experience: Experienced
  • OS: Windows 7
net use not going to EOF
« 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
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

Salmon Trout

  • Guest
Re: net use not going to EOF
« Reply #1 on: March 29, 2017, 11:47:10 AM »
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
exit

Salmon Trout

  • Guest
Re: net use not going to EOF
« Reply #2 on: March 29, 2017, 11:56:12 AM »
You 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