|
Answer» Hi,
Can someone help me creating a tracert batch file which run conti after 1 or 3 hr and print tracert report with different file name & date, TIME stamp, so that previously created tracert report not get merged.Your question doesn't have all the details but see if this works for you:
Code: [Select]echo off :loop
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & 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%" set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
tracert www.google.com >"%fullstamp%.txt"
goto :loop Thx for quick response...
but please suggest where i have to put hours like 1, 2 or 3 after that this batch file auto execute and create different log file from the PREVIOUS one.Explain what you need to do again.we want to create a batch file that -
1. Should run automatically after 3 hours 2. will run tracert & print out their RESULTS with date & time. 3. when same batch run after 3 hour then it should create another file for that tracert report with date & time.
I hope now I have explained it.Use Windows Scheduled Task to run the Batch file every 3 hours.Thanks guys... its really worked like a charm
Quote from: foxidrive on May 07, 2014, 08:32:49 AM Your question doesn't have all the details but see if this works for you:
Code: [Select]echo off :loop
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & 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%" set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
tracert www.google.com >"%fullstamp%.txt"
goto :loop
I know its an old thread, but for me it didn't worked untill I did this:
Code: [Select]echo off cd A:\NY\Directories\You\Want\Your\results\In :loop
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & 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%" set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
tracert www.google.com >"%fullstamp%.txt"
goto :loop With the original code, it created about 3-4 empty files PER seconds in the same directory. I am on Windows 7 64bit.
|