Hi,
My windows version is 10.1.18362
I need to change the system date, run a program then change the date back again. The following works fine but requires to be run as admistrator and won't give me the right date tomorrow.
date 01-03-07
filename.exe
pause
date 05-01-20
The next loads beforedate with 05-Jan-19 and sets the date to 01-04-09. "date %BEFOREDATE%" returns "The system cannot accept the date entered. Enter the new date (dd-mm-yy). I guess it doesn't like "Jan"
set BEFOREDATE=%date:~%
date 01-04-09
filename.exe
pause
date %BEFOREDATE%
I also need to run this without administraror.
Any help greatly appreciated.
Change the system date
Moderator: DosItHelp
Re: Change the system date
Dealing with dates is highly system dependent, so the following might (or mght not) help you (untested):
According to the linked site, your system admin give your non-admin-user-account the needed rights to change the date:
https://www.howtogeek.com/253745/how-to ... -and-date/
penpen
Code: Select all
@echo off
setlocal enableExtensions enableDelayedExpansion
for %%a in (
"jan=-01-" "feb=-02-" "mar=-03-" "apr=-04-" "mai=-05-" "jun=-06-"
"jul=-07-" "aug=-08-" "sep=-09-" "oct=-10-" "nov=-11-" "dec=-12-"
) do set %%a
set "BEFOREDATE=%date:-=!%"
date 01-04-09
filename.exe
pause
date %BEFOREDATE%
goto :eof
https://www.howtogeek.com/253745/how-to ... -and-date/
penpen
Re: Change the system date
That works perfectly. Thank you so much for your help.
Regards
Geoffwl
Regards
Geoffwl