Solved

net time vbs script not working

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem to With line 4 57
How to restore security permissions on a file server 4 54
Message Logon Windows 2012 R2 Server 16 26
Windows updates batch files 7 44
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…
Learn about cloud computing and its benefits for small business owners.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 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