Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Win XP date by VBScript

Status
Not open for further replies.

lumolux

Technical User
Dec 28, 2008
4
BR
I have a bat file that already does a job: changes Win XP date. I've been seeking in the internet for a script to change windows date by vbscript. Somebody can help?
 
Time synchronization should automatically happen in a domain. The PDC Emulator should automatically sync time with workstations.

Are you not in a domain?



I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
No, I'm not in a domain. In this case my computers are stand alone and what I want to do is: In any time change Win XP date to the date eg:12/22/2008 and then change it back to actual date eg:12/29/2008. This by VBScript`cause I have a batch that does that. Strange I have a bat(from a OS(DOS) 25 yars old) and I can't find a solution with this (they says powerfull tool) actual tool.
I really want to use WIN XP natural resources.


Anyway, Thanks.
 
Use the Shell object.

Code:
Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run "CMD.EXE /C DATE 12/22/2008"


I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Dear Mark,

Your code using a with constant date works good , but when using with a variable(what i need) does't.
I don´t know if is the way i tell the CMD.EXE to use the variable(NewDate)...
Trying to use your code, i have the following situation,
message from teh CMD.EXE window:

"The system cannot accept the date entered"

My code:

Dim OriginalDate,NewDate,OriginalTime, NewTime

OriginalDate = date() 'retrieve the current date
NewDate = #12/23/08# 'change this as needed

Set WSHShell = CreateObject("Wscript.Shell")
WSHShell.Run "CMD.EXE /c date newdate"


Thanks.
 

Code:
WSHShell.Run "CMD.EXE /c date [b]" & newdate[/b]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,


It worked... great!!!

Foruns like this must exist ever.
Thank you all.



lumolux.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top