I am creating a batch file that allows users to re-map their Home network share drive after a vpn connection has been made. Since the mapping is based on their profile, this won't push unless they logon while connected to our network.
We have many offsite locations so, I made it so they have to choose their location and it will map based on their local domain controller.
However, when using NET USE there are a few instances when errors can occur (always user error...)
For example. If they haven't vpn'd in yet, its going to throw an error stating that the network path cannot be found - I want to catch this error and replace it with something like "make sure you have a live internet connection and you can reach the intranet home page first, and try again"
Same goes for if they are allready mapped and they are running the batch file again, it will say something about the drive letter is already in use... and i would like to replace that error with "Your drive is already mapped, open your my computer and access your H:/ Drive"
title ~ AVI Information Technology ~ Map My Home Drive
@ECHO OFF
CLS
ECHO ------------------------------
ECHO Name of the Company
ECHO ------------------------------
ECHO Please select your home office location...
:LOOP
ECHO A. Altamonte
ECHO B. Atlanta
ECHO C. Cleveland
ECHO D. Columbia
ECHO E. Cypress
ECHO F. Dallas
ECHO G. Denver
ECHO H. Detroit
ECHO I. Ft. Lauderdale
ECHO J. Jacksonville
ECHO K. Lanham
ECHO L. Las Vegas
ECHO M. Nashville
ECHO N. New York
ECHO O. Orlando
ECHO P. Pittsburgh
ECHO Q. Salt Lake City
ECHO R. Tampa
ECHO Z. Quit
SET Choice=
SET /P Choice=Type the letter and press Enter:
IF NOT '%Choice%'=='' SET Choice=%Choice:~0,1%
ECHO.
:: /I makes the IF comparison case-insensitive
IF /I '%Choice%'=='A' GOTO ALT
IF /I '%Choice%'=='B' GOTO ATL
IF /I '%Choice%'=='C' GOTO CLE
IF /I '%Choice%'=='D' GOTO COL
IF /I '%Choice%'=='E' GOTO CYP
IF /I '%Choice%'=='F' GOTO DAL
IF /I '%Choice%'=='G' GOTO DEN
IF /I '%Choice%'=='H' GOTO DET
IF /I '%Choice%'=='I' GOTO FTL
IF /I '%Choice%'=='J' GOTO JAX
IF /I '%Choice%'=='K' GOTO LAN
IF /I '%Choice%'=='L' GOTO LSV
IF /I '%Choice%'=='M' GOTO NSV
IF /I '%Choice%'=='N' GOTO NYC
IF /I '%Choice%'=='O' GOTO ORL
IF /I '%Choice%'=='P' GOTO PIT
IF /I '%Choice%'=='Q' GOTO SLC
IF /I '%Choice%'=='R' GOTO TPA
IF /I '%Choice%'=='Z' GOTO End
ECHO "%Choice%" is not valid. Please try again.
ECHO.
GOTO Loop
:ALT
net use h: \\ALTDC1\users\%USERNAME% /persistent:yes
GOTO Again
:ATL
net use h: \\atldc1\users\%USERNAME% /persistent:yes
GOTO Again
:CLE
net use h: \\CLEdc1\users\%USERNAME% /persistent:yes
GOTO Again
:COL
net use h: \\COLdc1\users\%USERNAME% /persistent:yes
GOTO Again
:CYP
net use h: \\CYPdc1\users\%USERNAME% /persistent:yes
GOTO Again
:DAL
net use h: \\DALdc1\users\%USERNAME% /persistent:yes
GOTO Again
:DEN
net use h: \\DENdc1\users\%USERNAME% /persistent:yes
GOTO Again
:DET
net use h: \\DETdc1\users\%USERNAME% /persistent:yes
GOTO Again
:FTL
net use h: \\FTLdc1\users\%USERNAME% /persistent:yes
GOTO Again
:JAX
net use h: \\JAXdc1\users\%USERNAME% /persistent:yes
GOTO Again
:LAN
net use h: \\LANdc1\users\%USERNAME% /persistent:yes
GOTO Again
:LSV
net use h: \\LSVdc1\users\%USERNAME% /persistent:yes
GOTO Again
:NSV
net use h: \\NSVdc1\users\%USERNAME% /persistent:yes
GOTO Again
:NYC
net use h: \\NYCdc1\users\%USERNAME% /persistent:yes
GOTO Again
:ORL
net use h: \\ORLdc1\users\%USERNAME% /persistent:yes
GOTO Again
:PIT
net use h: \\PITdc1\users\%USERNAME% /persistent:yes
GOTO Again
:SLC
net use h: \\SLCdc1\users\%USERNAME% /persistent:yes
GOTO Again
:TPA
net use h: \\sid\TPA-Users\%USERNAME% /persistent:yes
GOTO Again
:Again
PAUSE
CLS
:End
I've been searching and searching, and can't find any error handling within batch files...
is there?
Thanks in advance