Post by JJI think this is a problem in the network communication part, where the
response timeout is too low. The problem is common in Windows (all
versions; even if power management is not interfering), but rarely
occur in Linux. So if there is a setting for that timeout, it would
be my prime suspect.
Thanks all for trying, but in the absence of a better command line
method, I used a work-around.
Since NET VIEW /NETWORK works for all machines sometimes, this saves
them for future reference so it doesn't need to find them every time.
Its purpose is to locate USB drives on whichever PC they might be
plugged in to, so a backup script can use the drive even if I moved it.
It does require that the remote PC has previously established a share on
the drive.
I called it FindVolSN.cmd and I can call it like this for example:
for /f "tokens=4" %%a in ('findvolsn 4278-8365') do backup %%a
The script follows, triple spaced to reveal line wrap:
@echo off
set _vol_sn_list=%*
if not defined _vol_sn_list goto :eof
rem searching for Volume Serial Number in LOCAL drives
for %%a in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do for /f
"skip=1 tokens=5" %%b in ('vol %%a: 2^>nul') do call :check_vol_sn %%a:
%%b
:get_unc_computers
rem searching for Volume Serial Number in NETWORK drives
rem parameters: none
rem scanning for all computer names in network (could take a few
minutes)
rem wake up the network
rem Share names found in the past were saved in the registry
rem so the other computers can be "awakened" by a DIR command.
for %%a in (%NETWORK_SHARE_LIST%) do for /l %%b in (1,1,10) do dir %%a
set "_in_computer_list="
for /f "tokens=1-4" %%a in ('net view /network') do (
if /i "%%a %%b %%c %%d"=="The command completed successfully." set
"_in_computer_list="
if not defined _in_computer_list (
rem if output is "----------" then the next line is a computer name
set "_text=%%a"
call set "_text=%%_text:~0,10%%"
call set "_text=%%_text:----------=%%"
if not defined _text set _in_computer_list=TRUE
) else (
if /i not "%%~a"=="\\%computername%" (
set "_compname=%%a"
call set "_doubleback=%%_compname:~0,2%%"
call set "_doubleback=%%_doubleback:\\=%%"
if not defined _doubleback call :get_unc_shares %%a
)
)
)
if defined NETWORK_SHARE_LIST setx /M NETWORK_SHARE_LIST
"%NETWORK_SHARE_LIST%">nul
goto :eof
rem =========subroutines=========
:get_unc_shares
rem parameters: 1 = UNC computer (i.e. \\ASUS)
set "_in_share_list="
for /f "tokens=1-4" %%w in ('net view %1') do (
if /i "%%w %%x %%y %%z"=="The command completed successfully." set
"_in_share_list="
if not defined _in_share_list (
rem if output is "----------" then the next line is a computer name
set "_text=%%~w"
call set "_text=%%_text:~0,10%%"
call set "_text=%%_text:----------=%%"
if not defined _text set _in_share_list=TRUE
) else (
if "%%x"=="Disk" call :get_vol_sn "%~1\%%~w"
)
)
goto :eof
:get_vol_sn
rem parameters: 1 = UNC share (i.e. \\ASUS\BU1)
for /f "skip=1 tokens=1-5" %%l in ('dir %1 2^>nul') do (
if /i "%%l %%m %%n %%o"=="Volume Serial Number is" call :check_vol_sn
%1 %%p
)
echo;%NETWORK_SHARE_LIST% | find /i "%~1">nul
if errorlevel 1 set NETWORK_SHARE_LIST=%NETWORK_SHARE_LIST% %1
goto :eof
:check_vol_sn
rem parameters: 1 = UNC share 2 = volume serial number
echo %_vol_sn_list% | find /i "%2" >nul 2>nul
if not errorlevel 1 echo Found %2 in %1
goto :eof
--