To check whether a batch file/script has been successfully executed, a condition check is generally included as the last command in the script. This condition checks the status of execution, and depending on whether or not the script was executed successfully, returns a value. A successful script execution returns a 0 while an unsuccessful one returns a non-zero value that is interpreted as an Error Code or an errorlevel.
Use the command EXIT /B %ERRORLEVEL% at the end of the batch file to return the error codes from the batch file
In the batch file , it is always a good practice to use environment variables instead of constant values. Since the same variable get expanded to different values on different computers.
Batch file for Copying File to a Folder
copy "\\sharename\foldername\samplefile.txt" "C:\manageengine"
exit /b %ERRORLEVEL%