Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Boombox
- Posts: 80
- Joined: 18 Oct 2012 05:51
#1
Post
by Boombox » 22 Oct 2012 07:21
.
Is there are more efficient way of doing this task?
Code: Select all
@echo off
for /f "tokens=1 delims=\" %%g in ('net view ^| findstr "\\"') do (
ping -4 -n 1 %%g | findstr "Pinging">>netlist.txt)
for /f "tokens=2,3" %%g in (netlist.txt) do echo %%g %%h& del netlist.txt
pause>nul
It works fine, but I can't help but feel that there's no need for that temporary file (netlist.txt).
Many thanks.
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 22 Oct 2012 15:50
Code: Select all
@echo off
for /f "tokens=1 delims=\" %%a in ('net view ^| findstr "\\"') do (
for /f "tokens=2,3" %%g in ('ping -4 -n 1 %%a ^| findstr "Pinging"') do (
echo %%g %%h
)
)
pause>nul
-
Boombox
- Posts: 80
- Joined: 18 Oct 2012 05:51
#3
Post
by Boombox » 22 Oct 2012 16:25
.
What!? I can use another FOR loop...?
But that opens up a whole new world of fun

Thanks again Foxi.