|Thanks for anyone's help in advance!|
I have created a batch file to check for a file folder, if not present to create it. Then to connect to a remote server and copy files to the local machine.
Specifically, I am requesting users enter the password for connecting to the server. There may be instances when users already have a connection to the server, and if they enter the password incorrectly I would like to suppress the system error and provide something more meaningful. Any way of suppressing system errors?
Here is my batch file:
echo. Check if the Folder Folder already exists on this machine.
if exist "C:\Folder" (
echo. Yes! Folder Folder Exists!
pause) else (echo. Folder Folder does not exist. Create folder now.
echo. Folder folder successfully created!)
echo. Connect to the server to copy the files.
echo. Checking connection to server. Please wait...
ping -n 1 192.168.150.14|find "Reply from" >NUL
if not errorlevel 1 goto:CONNECTSUCCESS
if errorlevel 1 goto:FAILURE
echo. The server cannot be reached. Contact your network admin. Hit any key to exit.
echo. Connection successful.
net use \\192.168.150.14\Folder$ * /user:UserBob\Folder
if not %errorlevel% NEQ 0 goto:COPYFROMSERVER
if %errorlevel% NEQ 0 goto:CONFIRMERROR
if errorlevel 2 goto:RESPONSE
REM 1219 is if connection alreadty exists with credentials, and user fails to put in password
REM 1326 is if NO connection exists, and user fails to put in password
echo. You have typed the password incorrectly. Please try again by pressing any key.
echo. Now copying files...
copy "\\192.168.150.14\Folder$\FolderApp\*.*" "C:\Folder"
echo. Done! You may now start Folder. Press any key to exit.
Thanks again for any help!