Batch File Question
Posted on 2014-04-23
I am working on a batch script to run the scanstate and loadstate part of the USMT tools. I have everything working the way I want but I want to prevent user error on a couple of parts so I will just include the sections in question.
On the script below, I want to be able to use the DIR command to check certain network share, give me a list of directories in that share and it then will ask the user to type the directory they want to use. It then gives a list of directories inside that directory and again it asks the user to specify which one they want to use.
What I want to do here is to be able to check the user input against the directories in the share and if there is a match use the GOTO command to move on to the next section but if there is no match I want to echo a message and then send the user back to the same section we were just working on.
At the moment this is not working like I would like to. My idea was to use the IF EXIST GOTO X and then IF NOT EXIST ECHO blahblah and GOTO Y
Anyone has any recommendations?
ECHO The following is a list of computers on the migration repository
ECHO Please select a computer from the list.
dir "\\SHARE\USMT\UserProfiles" /ad /O /P /W /B
Set /P MigComputer=Enter Computer Name of the computer you are migrating from:
ECHO Computer Name has been set to %MigComputer%
IF EXIST "\\SHARE\USMT\Userptofiles\%MigComputer%" (
IF NOT EXIST "\\SHARE\USMT\Userptofiles\%MigComputer%" (
ECHO %MigComputer% does not exist. Please check your spelling.
IF NOT EXIST "\\HCDC\Public\USMT\Userptofiles\%MigComputer%" (
dir "\\SHARE\USMT\UserProfiles\%MigComputer%" /ad /O /P /W /B
Set /P Miguser=Enter profile name of the user you are migrating:
ECHO User has been set to %MigUser%