Skip to content

Instantly share code, notes, and snippets.

@justincampbell
Created July 20, 2010 14:21
Show Gist options
  • Save justincampbell/483017 to your computer and use it in GitHub Desktop.
Save justincampbell/483017 to your computer and use it in GitHub Desktop.
Threaded batch script
@echo off
set strVariable=[%1]
if %strVariable% NEQ [] goto :Thread
set intTotal=0
echo Start %date% %time%
for /F %%a in ('net view ^| find /i "\\"') do call :Parse %%a
echo Stop %date% %time%
echo Total %intTotal%
goto :eof
:Parse
set strHost=%1
set strHost=%strHost:\=%
start threaded.bat %strHost%
set /a intTotal=%intTotal%+1
exit /b
:Thread
ping %1 -n 1 >nul
if %errorlevel% NEQ 0 exit
::Do some stuff to this host
::Save the data somehow if needed
::Could use sqlcmd, or flat files, or possibly save to system variables
exit
@djangofan
Copy link

Would be a good way to do a threaded XCOPY .... sorta like RichCopy.exe .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment