jbcom41
jbcom41

Reputation: 49

Script not logging to log file

trying to get this bat file to work, think I am close... can someone please help?

@echo on
for /f "delims=" %%i in ("netstat -anp TCP | find "ESTABLISHED"| find "3389"") do (
      echo %date% %time% %%i >>C:\Users\xxxx\Desktop\rdp.csv
      )
pause

Upvotes: 0

Views: 16

Answers (1)

Matt Williamson
Matt Williamson

Reputation: 7095

Have you tried running your code without the file redirection?

Try this:

@echo on
for /f "delims=" %%i in ('netstat -anp TCP^| find "ESTABLISHED"^| find "3389"') do (
      echo %date% %time% %%i 
      )
pause

You needed to escape your pipes and use single quotes in the for loop.

Upvotes: 2

Related Questions