I have a batch file that copies some files from different network shared drives to my own computer.
I have set a log file for recording if any error occurs at any point, but am not able to specify the particular drive's name in that error log for which the error has occurred.
My batch code:
@ECHO OFF
set LOGFILE=Backup.log
call :L 2>> %LOGFILE%
EXIT /B
:LOG
***echo --------Drive "c03f"--------- >> Backup.log*** --to print network drive's name in the log file. Please ignore the star mark and the double quotes--
net use p: \\10.210.162.171\Packages && copy p:\run.log d:\Files
:LOG
echo --------Drive "c04f"--------- >> Backup.log
net use p: \\10.210.162.192\Packages && copy p:\run.log d:\Files
:LOG
echo --------Drive "c05f"--------- >> Backup.log
net use p: \\10.210.162.196\Packages && copy p:\run.log d:\Files
Expected Result in the error log file:
--------Drive c03f---------
network name not valid
Cannot connect to the system.
--------Drive c04f---------
network name not valid
Cannot connect to the system.
--------Drive c05f---------
1 File(s) copied
Current result in the error log file: -
network name not valid
Cannot connect to the system.
network name not valid
Cannot connect to the system.
1 File(s) copied
This is what I'm doing and after `:LOG.
It is not giving the network shared drive name the way I want to. Since, there are total three drives and for each one there are same set of commands, I'm not able to deduce for which network shared drive this error has occurred.
There are total three same statements with different drive names and different IPs. I'm doing this in Windows 10. All other network connected PCs are also Windows 10.