Talking to someone about y2k38 the other day, I thought of a prank: using VBS to change the system to January 19, 2038 3:14 07 seconds, so some programs that rely on the Unix timestamp will go wrong. So how do you change the time of the system with the VBS?
The simplest and least technical method is to invoke the date and time command for CMD:
Copy Code code as follows:
' Author:demon
' website:http://demon.tw
' Date:2011/4/27
Dim WshShell
Set WshShell = CreateObject ("WScript. Shell ")
Wshshell.run "cmd.exe/c date 2038-01-19", 0
Wshshell.run "cmd.exe/c time 3:14:08", 0
A more technical approach is to use the SetDateTime method of the WMI Win32_OperatingSystem class:
Copy Code code as follows:
' Author:demon
' website:http://demon.tw
' Date:2011/4/27
Dtmnewdatetime = "20380119031408.000000+480" ' UTC time
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
Windows 7 requires administrator privileges to change the time when UAC is turned on, which is no fun at all.
Reference Links: Hey, scripting guy!. How Can I Set the "Date and Time" on a Computer?
From: http://demon.tw/programming/vbs-modify-system-time.html