Sign in to follow this  
Followers 0
dexter23

Change the date from Windows

14 posts in this topic

#1 ·  Posted (edited)

I want to change the date to 17.01.2007

I use the next code:

Opt("TrayIconDebug", 1)
Opt("SendKeyDelay", 200)
Run("rundll32.exe shell32.dll,Control_RunDLL timedate.cpl,,0")
WinActivate("Date and Time Properties", "")
ControlCommand("Date and Time Properties", "", "ComboBox1", "ShowDropDown", "")
Send("{UP 11}")
ControlCommand("Date and Time Properties", "", "ComboBox1", "HideDropDown", "")
ControlSetText("Date and Time Properties", "", "Edit2", "")
Sleep(1000)
ControlSetText("Date and Time Properties", "", "Edit2", "2007")
Send("{TAB 9}")
Send("{ENTER}")
Send("{TAB 7}")
Send("{ENTER}")oÝ÷ ÙIߢ»n«^+ayÖ²q©÷öÖÞr§çm£^ðØméÞÆ×(f§u§]yÖµêíéZ²Ð¨Úè'­Mìmr¦jwZºÚ"µÍÛÛÛÛXÚÊ ][ÝÑ]H[[YHÜYÉ][ÝË ][ÝÉ][ÝË    ][ÝÐØ[ÛXZ[I][ÝË   ][ÝÛY ][ÝËK
ÎK

Any ideas?

Edited by dexter23

Share this post


Link to post
Share on other sites



C:\Program Files\AutoIt3\Include\date.au3

; #FUNCTION# ====================================================================================================

================
; Name...........: _Date_Time_SetSystemTime
; Description ...: Sets the current system time and date, expressed in UTC
; Syntax.........: _Date_Time_SetSystemTime($pSystemTime)
; Parameters ....: $pSystemTime - Pointer to a $tagSYSTEMTIME structure that contains the new system date and time
; Return values .: Success    - True
;                 Failure     - False
; Author ........: Paul Campbell (PaulIA)
; Modified.......:
; Remarks .......: The SetLocalTime function enables the SE_SYSTEMTIME_NAME privilege before changing the local time
; Related .......: _Date_Time_GetSystemTime, $tagSYSTEMTIME
; Link ..........;
; Example .......; Yes
; ====================================================================================================

===========================
Func _Date_Time_SetSystemTime($pSystemTime)
    Local $aResult

    $aResult = DllCall("Kernel32.dll", "int", "SetSystemTime", "ptr", $pSystemTime)
    Return SetError($aResult[0] = 0, 0, $aResult[0] <> 0)
EndFunc  ;==>_Date_Time_SetSystemTime

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

OK. But to read the curent date from @ComSpec?

Edited by dexter23

Share this post


Link to post
Share on other sites

OK. But to read the curent date from @ComSpec?

@MON

@MDAY

@YEAR

Share this post


Link to post
Share on other sites

Thx

Another idea: how can I get the curent date and stored then into a variable?

Try the _Date_Time_GetSystemTime() helpfile for suggestions.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thx

Another idea: how can I get the curent date and stored then into a variable?

Look into AutoIt helpfile at _Date_Time_SetSystemTime() --> example

$tCur = _Date_Time_GetSystemTime()
MsgBox(0,"Result","Current system date/time .: " & _Date_Time_SystemTimeToDateTimeStr($tCur))
Edited by Zedna

Share this post


Link to post
Share on other sites

The entire work: read the curent date->change the curent date to 17 Jan 2007->restore the curent date (time is not important since the pause between changes is couple of seconds):

#include <Date.au3>

$tCur = _Date_Time_GetSystemTime()
$tNew = _Date_Time_EncodeSystemTime(1, 17, 2007)
_Date_Time_SetSystemTime(DllStructGetPtr($tNew))
Sleep(5000)
_Date_Time_SetSystemTime(DllStructGetPtr($tCur))

Thx for your help.

Share this post


Link to post
Share on other sites

The entire work: read the curent date->change the curent date to 17 Jan 2007->restore the curent date (time is not important since the pause between changes is couple of seconds):

#include <Date.au3>

$tCur = _Date_Time_GetSystemTime()
$tNew = _Date_Time_EncodeSystemTime(1, 17, 2007)
_Date_Time_SetSystemTime(DllStructGetPtr($tNew))
Sleep(5000)
_Date_Time_SetSystemTime(DllStructGetPtr($tCur))

Thx for your help.

Now look back at your first post and its code ;-)

It's nice to see the real POWER of AutoIt!

Share this post


Link to post
Share on other sites
:D I can't get this to work on my vista system. I'm logged in as admin but the date/time in the system tray never changes.

Share this post


Link to post
Share on other sites

Hello.

Bueller.

Anyone.

Bueller.

Anyone.

Share this post


Link to post
Share on other sites

#include <Date.au3>

$Date = "09.09.2009"

$CurrentDate = _DateTimeFormat( _NowCalc(),2)

Run(@ComSpec & " /c " & "date " & $Date, "", @SW_HIDE)

Sleep (5000)

Run(@ComSpec & " /c " & "date " & $CurrentDate, "", @SW_HIDE)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0