1.

Solve : Batch file to ping everyday and save in notepad?

Answer»

Hello,

Please i need to create a batch file to check whether a server is on everyday and save
the results in a notepad folder on the desktop.

Kindly assist me with this.

Thanks in advance.

Do you have any code to START with?Please no code at the moment. Quote from: Akod on September 10, 2014, 05:25:09 AM

Please no code at the moment.

ok.  Which server are you going to ping?  An internet server or a local server on the LAN?

or do you have to do this for an assignment?A local server on LAN Code: [Select]echo off
ping IPADDRESS >>"C:\path to\logfile.txt"Use Windows Task Scheduler to have it run every day at the time you WANT it to run.Please how can i make it name itself after the current date so that it will not replace each other?Please explain in better detail what you are trying to do.  Please list examples of what you want.  If you KEEP changing the parameters of what you need eventually people will not help you with your problem.The solution you GAVE saves the notepad file with the name logfile. I will prefer if it saves it with the name of the current date. This will change the name of the TEXT file with the current date.
Code: [Select]echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do SET "dt=%%a"
set "YYYY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%"
set "Min=%dt:~10,2%"
set "Sec=%dt:~12,2%"
set "datestamp=%YYYY%%MM%%DD%"
set "timestamp=%HH%%Min%%Sec%"
ping IPADDRESS >>"C:\path to log\%datestamp%.txt"Thanks.


Discussion

No Comment Found