QUOTE (pcalvert @ Mar 8 2007, 01:14 PM)

I am trying to write a batch file that will run netstat and send the output to a text file. Here is what I
I tried this on Windows 98 SE and it doesn't work. When I execute the batch file (netstat.bat), the command scrolls across the screen (inside the MS-DOS window) repeatedly, and I have to close the MS-DOS window instead of letting the batch file finish. And although the output file netstat-out.txt was created, it is a zero-byte file with nothing in it.
Phil
EDIT: it IS caused by your use of a RESERVED word ... change the name of Netstat.bat to something else and it will work.
My original post text - obsolete now
CODE
it really should work... does NETSTAT -an work from the command line? i couldn't replicate your problem ... try this code in a bat file:
[code]@echo off
echo.
IF NOT EXIST "C:\My Documents\nul" echo "C:\My Documents" could not be found...
IF NOT EXIST "C:\My Documents\nul" echo PAUSE
IF NOT EXIST "C:\My Documents\nul" echo goto END
echo.
echo. Now turning off directory protection...
rem|choice>NUL /c:c /n /t:c,1
ATTRIB -H -S -R "C:\My Documents"
echo.
echo. Now writing output file...
rem|choice>NUL /c:c /n /t:c,1
netstat -an> "C:\My Documents\netstat-out.txt"
rem|choice>NUL /c:c /n /t:c,1
echo.
echo. Now turning directory protection back on...
rem|choice>NUL /c:c /n /t:c,1
ATTRIB +S "C:\My Documents"
echo.
echo. Now checking that the file exists...
rem|choice>NUL /c:c /n /t:c,1
IF NOT EXIST "C:\My Documents\netstat-out.txt" goto NOLUCK
echo.
echo. File was found! Yay!
echo.
PAUSE
goto END
:NOLUCK
echo.
echo. File was not found... sigh.
echo.
PAUSE
:END
CLS
EXIT