Logging With Batch File

Joined
Apr 3, 2010
Messages
1
Reaction score
0
Hi, I made a batch file that logs everything to a txt file, but I want it to OVERWRITE every time it logs, instead of just adding to what is already in the log file.

Here is what I have so far in my batch file:

Code:
@Echo Off
Echo "Important!: Leave this window open until scan is finished"
SetLocal EnableDelayedExpansion
Set _Start=20
Set _End=23
Set _NoPings=1
Set _Site=192.168.1.1
Set _Found=%~dp0Portfound.txt
Set _Log=%~dp0Portlog.txt
Del "%_Log%"
For /L %%I In (%_start%,1,%_End%) Do (
Echo Testing port %%I >>"%_log%"
  >Nul 2>&1 tcping -n %_NoPings% %_Site% %%I
  If !ErrorLevel!==0 (
	>>"%_Found%" Echo "Success! Port %%I is open"
  ) Else (
	>>"%_Log%" Echo "Port %%I is not open"
  ))

This batch file logs where it is supposed to, but I want it to overwrite everything in the log file, instead of adding to it.

Any Ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top