how to trap The Network path was not found

March 2, 2011 at 18:58:32
Specs: Windows 7
I am attempting to create a batch file to check dir size on several servers and trap the error "the network path... and write it to a log file then continue down the list of servers. The output is correct for the servers taht are available but nothing is echoed to the Log if the server is uncontactable. "The network path was not found" is echoed in the Command window.

for /f "tokens=* delims= " %%a in (Server1.txt) do for /f "tokens=3" %%x in ('dir \\%%a%dir% /-c ^| find "File(s)"') do (call :sub1 "%%x" "%%a")

:sub1
if not ERRORLEVEL 0 echo %2 is not available >> %logs%
set /a MB=(%1/1024)/1024 >> %logs%
echo Size of the %2%dir% is %1 bytes >> %logs%


See More: how to trap The Network path was not found

Report •

#1
March 3, 2011 at 08:57:16
Untested:

for /f "tokens=* delims= " %%a in (Server1.txt) do for /f "tokens=3" %%x in ('2>errorfile.log dir \\%%a%dir% /-c ^| find "File(s)"') do (call :sub1 "%%x" "%%a")
:sub1
if not ERRORLEVEL 0 echo %2 is not available >> %logs%
set /a MB=(%1/1024)/1024 >> %logs%
echo Size of the %2%dir% is %1 bytes >> %logs%

You may have to escape >?

When your only tool is a hammer, every problem looks like a nail.


Report •
Related Solutions


Ask Question