Solved

net time vbs script not working

Posted on 2007-11-29
4
1,701 Views
Last Modified: 2012-08-13
I have a below script

Dim wshShell

Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "%COMSPEC% /c net time \\dc3 /set /y", 0, True

Set wshShell = Nothing

It is suppose to set the time on the domain pcs and servers to dc3 time and all pcs and servers are to draw time from this domain controller(which I have set up to draw time from ntp pool of usa servers)




But when I run net time in command prompt on a pc or other server it shows time drawing from  another server(dc1).

I want all pcs and servers in domain to draw time from dc3 using this script in login script. The script is suppose to do this.......why is it when I run net time on a different pc or server.... it shows pulling from dc1......the below is the full script

ON ERROR RESUME NEXT

Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "%COMSPEC% /c net time \\dc3 /set /y", 0, True
Set wshShell = Nothing
UserString = WSHNetwork.UserName
WSHNetwork.MapNetworkDrive "S:", "\\fileserv\shared"
WSHNetwork.MapNetworkDrive "U:", "\\fileserv\users\" & UserString
WSHNetwork.MapNetworkDrive "g:", "\\rta1\fleet"
WSHNetwork.MapNetworkDrive "K:", "\\keller\keller"



If need be can I change the script to pull from a ntp server and set that into login script?? If so how??

Open in new window

0
Comment
Question by:heydorft
  • 2
4 Comments
 
LVL 51

Expert Comment

by:Netman66
ID: 20378825
wshShell.Run "C:\Windows\System32\CMD.exe /c net time \\dc3 /set /y", 0, True

Try that.

0
 

Author Comment

by:heydorft
ID: 20379079
That did not work
0
 
LVL 51

Expert Comment

by:Netman66
ID: 20379175
Normally, domain members sync with the PDC by default.

You can use Group Policy to push out this change here:

Computer Config>Admin Templates>System>Windows Time Service>Time Providers ::

Enable Windows NTP Client = Enabled.
Configure Windows NTP Client = Enabled.  Set your server FQDN followed by 0x1 (dcs.domain.local,0x1).  Leave the rest alone.

This should by set on a policy above the workstations.  

Make sure that DC3 has been set to sync with a time server on the internet.  You'll also have to tell your other DCs to use this server too or your AD timestamps will be a mess.

0
 
LVL 12

Accepted Solution

by:
StuFox100 earned 500 total points
ID: 20386037
It looks like you are running this a user script this will not work as users don't have permission to change system time by default.
The best solution is to move the "net time" script to a startup script as it runs as system.
Cheers
Stu
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question