Page 1 of 1

Changing pc time

PostPosted: Tue Sep 22, 2015 9:10 am
by carlos torres
Hi everyone

Curiosity, it is possible to change the time on the computer by code?

regards
carlost

Re: Changing pc time

PostPosted: Tue Sep 22, 2015 10:03 am
by stu
Yes sir, using vBScript

Syntax: [ Download ] [ Hide ]
Using Visual Basic Syntax Highlighting
dtmNewDateTime = "20071115132000.000000-480"
strComputer = "."
Set objWMIService = GetObject("winmgmts:{(Systemtime)}\\" & strComputer & "\root\cimv2")

Set colOSes = objWMIService.ExecQuery("Select * From Win32_OperatingSystem")

For Each objOS In colOSes
    objOS.SetDateTime dtmNewDateTime
Next
Parsed in 0.003 seconds, using GeSHi 1.0.8.10


btw, here's the Source with all the details ;)

Re: Changing pc time

PostPosted: Wed Sep 23, 2015 7:43 am
by carlos torres
Thanks Stu
I will try your suggestion.

regards
carlost

Re: Changing pc time

PostPosted: Sun Sep 27, 2015 7:49 am
by CN_Iceman
Another way...

Code: Select all
SetVar "[New_Time]" "15:30:00"
Run "Time" "[New_Time]" "RunOnce+Wait+LoadComplete+Minimized+Hidden" "" ""