hello so i am new here and trying to create a batch that advancesa month every...20 seconds for example
i have this script which i was able to compile however to do what i want to do i have to keep changing the date manually on the script
set before=%date%
echo 04/06/2017 | date
ping localhost -n 15
echo %before% | date
so i am after a way to set it to repeat but change by a month at a time
as the way ive done it i have to change it myself instead of it doing this for example:
set before=%date%
echo 04/07/2017 | date
ping localhost -n 15
echo echo 04/08/2017 | date
ping localhost -n 15
echo echo 04/09/2017 | date
but i would be sitting here for some time writing out infinite dates
many thanks and any advice is welcome im new to scripting
Trying to advance time two weeks at a time
Moderator: DosItHelp
Re: Trying to advance time two weeks at a time
You should avoid playing with date and time, because there may be unwanted side effects:
For example some virus scanners may notice the date modification of one month and handle it as "another month worked", so the (possibly paid) virus protection expires another month earlier (even if you restore the date).
Nevertheless, if you want to get the values (assuming your system is using the date format dd/mm/yy), then this might help you:
You then can change the values using "set /a" for example.
penpen
For example some virus scanners may notice the date modification of one month and handle it as "another month worked", so the (possibly paid) virus protection expires another month earlier (even if you restore the date).
Nevertheless, if you want to get the values (assuming your system is using the date format dd/mm/yy), then this might help you:
Code: Select all
:: get date format and values
for /f "tokens=1-3 delims=./-" %%a in ("%before%") do (
set "day=%%~a"
set "month=%%~b"
set "year=%%~c"
)
:: remove trailing zeroes and inc month value
set "day=%day:*0=%"
set "month=%month:*0=%"
penpen
Re: Trying to advance time two weeks at a time
penpen wrote:You should avoid playing with date and time, because there may be unwanted side effects:
For example some virus scanners may notice the date modification of one month and handle it as "another month worked", so the (possibly paid) virus protection expires another month earlier (even if you restore the date).
Nevertheless, if you want to get the values (assuming your system is using the date format dd/mm/yy), then this might help you:You then can change the values using "set /a" for example.Code: Select all
:: get date format and values
for /f "tokens=1-3 delims=./-" %%a in ("%before%") do (
set "day=%%~a"
set "month=%%~b"
set "year=%%~c"
)
:: remove trailing zeroes and inc month value
set "day=%day:*0=%"
set "month=%month:*0=%"
penpen
many thanks and this will literally be ran on a pc with nothing more then the OS.... and the application im trying to manipulate as it will be running most of the time.
many thanks