Solved

net time vbs script not working

Posted on 2007-11-29
4
1,710 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Learn about cloud computing and its benefits for small business owners.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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