@echo off if "%2"=="" goto usage if not exist %1 goto nodir del /Q %2 for /f %%a in ('dir /s /a:d /b %1') do echo NET SHARE "%%~nxa$"=%%a>>%2 echo. echo Output file %2 created. Run this to create the shares echo. goto end :usage echo. echo %0 echo Usage: %0 startdir outputfile echo. goto end :nodir echo. echo %0 echo Start directory "%1" does not exist. echo. :end