lgkoliveira Posted January 5, 2021 Posted January 5, 2021 I need to travel back five years to the past... jokes appart, I need to set the system date 5 years ago to use a WinXP Software at work, but i don't know how do it. I tried setting a command line in dos, but the command 'date' only sets the full date, not only the years. I did this, for example: $yearsago = "date 01/01/2016" Run(@Comspec & " /c " & $yearsago) This works, I can set 01/01/2016 for instance, but when I finish doing what I have to do I must set the actual date. Can anyone help me?
Musashi Posted January 5, 2021 Posted January 5, 2021 _Date_Time_SetSystemTime "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
Earthshine Posted January 5, 2021 Posted January 5, 2021 This looks troublesome. Why would you have to set the time back In order to use a piece of software? FrancescoDiMuro 1 My resources are limited. You must ask the right questions
pseakins Posted January 6, 2021 Posted January 6, 2021 (edited) I haven't tested this and I have the nasty bit remmed out but this should toggle your system clock as required. This was a bit of fun and is an adaptation of the help example for _Date_Time_SetSystemTime() Just uncomment the last 4 lines. ; Delorean.au3 Toggle system year between now and five years ago #include <Date.au3> $tCur = _Date_Time_GetSystemTime() ; Get current system time $sSysTime = _Date_Time_SystemTimeToDateTimeStr($tCur) ; convert to mm/dd/yyyy hh:mm:ss $iMon = Number(StringMid($sSysTime, 1, 2)) $iDay = Number(StringMid($sSysTime, 4, 2)) $iYear = Number(StringMid($sSysTime, 7, 4)) $iHour = Number(StringMid($sSysTime, 12, 2)) $iMin = Number(StringMid($sSysTime, 15, 2)) $iSec = Number(StringMid($sSysTime, 18, 2)) If $iYear < 2021 Then $iYear += 5 ; bring it back to the future Else $iYear -= 5 ; engage flux capacitor EndIf $tNew = _Date_Time_EncodeSystemTime($iMon, $iDay, $iYear, $iHour, $iMin, $iSec) ; m, d, y, h, min, s ;~ If Not _Date_Time_SetSystemTime($tNew) Then ;~ MsgBox($MB_SYSTEMMODAL, "Error", "System clock cannot be SET" & @CRLF & @CRLF & _WinAPI_GetLastErrorMessage()) ;~ Exit ;~ EndIf Edited January 6, 2021 by pseakins typo Phil Seakins
caramen Posted January 6, 2021 Posted January 6, 2021 On 1/5/2021 at 2:28 PM, Earthshine said: This looks troublesome. Why would you have to set the time back In order to use a piece of software? Of course for license reasons.... I guess. My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki
Earthshine Posted January 6, 2021 Posted January 6, 2021 isn't that against forum rules? My resources are limited. You must ask the right questions
Developers Jos Posted January 6, 2021 Developers Posted January 6, 2021 (edited) 1 hour ago, Earthshine said: isn't that against forum rules? Don't worry... we ( MODs) are following topics and will act when needed. You can obviously also report the thread, but then please only when it is confirmed going against the rules as till now there is no evidence, hence you didn't see any action yet after your first report. So having said all of this: halve of the posts in this thread are now off-topic, so please don't post unless it is on-topic and let us do our work. Edited January 6, 2021 by Jos Musashi 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
mikell Posted January 7, 2021 Posted January 7, 2021 On 1/5/2021 at 12:44 PM, lgkoliveira said: the command 'date' only sets the full date, not only the years Hmm this works for me (date in french format) ; set old $dateold = @MDay & "/" & @Mon & "/" & @Year-5 ; 2021 - 5 = 2016 Run(@ComSpec & " /c " & "date " & $dateold, "", @SW_HIDE) ; back $currentdate = @MDay & "/" & @Mon & "/" & @Year+5 ; 2016 + 5 = 2021 Run(@ComSpec & " /c " & "date " & $currentdate, "", @SW_HIDE)
lgkoliveira Posted January 8, 2021 Author Posted January 8, 2021 On 1/6/2021 at 2:20 PM, Earthshine said: isn't that against forum rules? Why would it be?
lgkoliveira Posted January 8, 2021 Author Posted January 8, 2021 22 hours ago, mikell said: Hmm this works for me (date in french format) ; set old $dateold = @MDay & "/" & @Mon & "/" & @Year-5 ; 2021 - 5 = 2016 Run(@ComSpec & " /c " & "date " & $dateold, "", @SW_HIDE) ; back $currentdate = @MDay & "/" & @Mon & "/" & @Year+5 ; 2016 + 5 = 2021 Run(@ComSpec & " /c " & "date " & $currentdate, "", @SW_HIDE) This is very good, thanks again. I used another command line, just to sync with the time set in our server (for setting the actual time and date). I did this: RunWait(@ComSpec & " /c " & 'net time /DOMAIN:MyDomain /SET /YES', "", @SW_HIDE)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now