Listing 1. ShareCapture 1 @Echo Off 2 Set Servername=work1 3 For /f "tokens=1 skip=4" %%i In ('Rmtshare \\%Servername% ^| Findstr /l /v "IPC$ ADMIN$ successfully." ^| Findstr /b /i /v /c:"[A-Z][$]"') Do (Set Share=%%i) & (Call :SECONDTRY) 4 Echo Capture Run Complete 5 Pause 6 Exit 7 :SECONDTRY 8 For /f "tokens=1,*" %%i In ('Rmtshare \\%Servername%\%Share% ^| Findstr /I "Remark"') Do (Set Remark=%%j) 9 If "%Remark%"=="" For /f "tokens=2" %%i In ('Rmtshare \\%Servername%\%Share% ^| Findstr /I "Path"') Do Echo Rmtshare \\%Servername%\%Share%=%%i /unlimited >>C:\RecreateShare.bat & Goto :Last 10 For /f "tokens=2" %%i In ('Rmtshare \\%Servername%\%Share% ^| Findstr /I "Path"') Do Echo Rmtshare \\%Servername%\%Share%=%%i /unlimited /remark:"%Remark: =%">>C:\RecreateShare.bat 11 :LAST 12 Goto :EOF Here is what is occurring in each step in ShareCapture.bat: 1. Turns off Echo to the console window. 2. Assigns the server name to %Servername%. 3. Filters out nonapplicable entries and lines. Captures the first share on the Work1 server, and sets %Share% to the share name. Moves the flow to :SECONDTRY. 4. Generates the message Capture Run Complete when the script finishes executing (i.e., loops through all the possible shares, as the note for step 12 explains). 5. Makes the script pause temporarily until a key is struck so that you can read the completion message. 6. Makes the script exit. 7. Flags the :SECONDTRY procedure. 8. Filters Rmtshare's output, and sets the share description to %Remark%. 9. Occurs if %Remark% is empty. Echoes output to RecreateShare.bat, then jumps to :Last. 10. Occurs if %Remark% isn't empty. Echoes output (including the /remark: switch and space-minimizing code) to RecreateShare.bat. 11. Flags the :LAST procedure. 12. Sends the flow back to where you called :SECONDTRY. The For command then selects the next share and the whole process repeats until no more shares exist.