Sign in to follow this  
Followers 0

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



#2 ·  Posted

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

#3 ·  Posted

Run(@ComSpec & " /c " & 'date 17.1.2008', "", @SW_HIDE)oÝ÷ Ûú®¢×k&Þjëh×6Run(@ComSpec & " /c " & 'date 01-17-2007', "", @SW_HIDE)

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

#5 ·  Posted

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

@MON

@MDAY

@YEAR

Share this post


Link to post
Share on other sites

#8 ·  Posted

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

#10 ·  Posted

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

#11 ·  Posted

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

#12 ·  Posted

: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

#13 ·  Posted

Hello.

Bueller.

Anyone.

Bueller.

Anyone.

Share this post


Link to post
Share on other sites

#14 ·  Posted

#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