My below script doesn't seem to be looping for all entries in devices.ini. It should loop and repeat the script for every entry (device dns name) in devices.ini but it only does the first entry and then the script closes. I'm guessing it's because of the GOTO statements? Anyone shed any light why and how I can get around it?
Thanks
Thanks
Code:
@echo off
FOR /f %%i in (devices.ini) DO (
ECHO -----------------%%i----------------- >>Results.txt
ECHO. >>Results.txt
NET USE /D N:
CLS
ECHO ##################################
ECHO ## MARS RPBE Client Installer ##
ECHO ## Version 1.0 ##
ECHO ## By Matt Page ##
ECHO ##################################
ECHO.
ECHO Connecting to %%i...
NET USE N: \\%%i\c$ /USER:XXXXXXXX
CLS
IF NOT %ERRORLEVEL% == 0 GOTO MAPFAIL
ECHO Installing MARS on %%i
ECHO PLEASE WAIT...
XCOPY DRSAPPS\*.* N:\DRSApps /S /E /C /I /Y
IF NOT %ERRORLEVEL% == 0 GOTO COPYDRSFAIL
CLS
ECHO Creating Food Services folder on stores desktop...
IF NOT EXIST "N:\Documents and Settings\Stores\Desktop\Food Services" GOTO FOLDER
GOTO ICON
:FOLDER
MKDIR "N:\Documents and Settings\Stores\Desktop\Food Services"
GOTO ICON
CLS
:ICON
ECHO Copying Shortcuts to Food Services folder for Stores user...
XCOPY "\DRSApps\MARS LIVE.lnk" "N:\Documents and Settings\Stores\Desktop\Food Services" /S /E /C /I /Y
XCOPY "\DRSApps\MARS TEST.lnk" "N:\Documents and Settings\Stores\Desktop\Food Services" /S /E /C /I /Y
IF NOT %ERRORLEVEL% == 0 GOTO COPYICONFAIL
GOTO SUCCESS
ECHO %%i
PAUSE
:MAPFAIL
ECHO Failed to connect to device >>Results.txt
ECHO Aborting Installation >>Results.txt
ECHO Moving to next device... >>Results.txt
GOTO FINISH
:COPYDRSFAIL
ECHO MARS RPBE Client Installation failed >>Results.txt
ECHO Aborting Installation >>Results.txt
ECHO Moving to next device... >>Results.txt
GOTO FINISH
:COPYICONFAIL
ECHO MARS Icon creation failed >>Results.txt
ECHO Aborting Installation >>Results.txt
ECHO Moving to next device... >>Results.txt
GOTO FINISH
:SUCCESS
ECHO Successfully Installed MARS RPBE Client >>Results.txt
ECHO Moving to next device... >>Results.txt
:FINISH
ECHO. >>Results.txt
ECHO ----------------------------------------- >>Results.txt
ECHO. >>Results.txt
ECHO. >>Results.txt
)