Saved Bookmarks
| 1. |
Solve : Batch file to ping everyday and save in notepad? |
|
Answer» Hello, 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. |
|