Solved

net time vbs script not working

Posted on 2007-11-29
4
1,690 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Learn about cloud computing and its benefits for small business owners.
ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now