none
Appending to existing script to execute net time RRS feed

  • Question

  • Hello Everyone -

    I hope I'm posting this to the correct location.  First thing to clarify is that I'm not a scripting person.  I'm just trying to figure out how to add to my existing, functional script.

    Basically, I'm trying to add the "net time" command so that my workstations will sync up with the PDC emulator.  I have found some examples out there and tried them, but to no avail.  Below is what I have tried adding.  The script is running because I receive a drive mapping that is configured in the script.  I do not receive any syntax errors with what I've added.  If I put that same net time command into a batch file and run it as administrator it fixes the time on the workstation I'm testing with.

    Any thoughts on why this is not working within the vbs script but will work within a separate batch file?

    Any help would be appreciated.

    Dim wshell
    Set wshell = CreateObject("WScript.Shell")
    wshell.Run "net time \\DC1 /SET /YES",0,TRUE
    set wshell = Nothing

    Tuesday, January 19, 2016 10:52 PM

Answers

  • As Mike noted, standard users lack the privilege to change the system clock, so you can't do this in a logon script.

    You need to post domain configuration questions (including time synchronization) in the Directory Services forum.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, January 20, 2016 3:48 PM
    Moderator

All replies

  • Domain members automatically synchronize their clocks with an authoritative time source (a domain controller). This is critical to correct Kerberos functioning in a domain. You should not be trying to script this with the "net time" command. Start with the TechNet documentation.

    -- Bill Stewart [Bill_Stewart]

    • Proposed as answer by jrv Tuesday, January 19, 2016 11:26 PM
    Tuesday, January 19, 2016 11:10 PM
    Moderator
  • You are correct.  However, I have many domain workstations that are not syncing their time correctly with the DC's.  I have looked at all the TechNet articles and have attempted time setup via that documentation.


    • Edited by timahh2 Wednesday, January 20, 2016 2:25 PM
    Wednesday, January 20, 2016 2:20 PM
  • You are correct.  However, I have many domain workstations that are not syncing their time correctly with the DC's.

    Then you really need to fix the root of the problem and not use a bandaid script.

    Wednesday, January 20, 2016 2:22 PM
  • With all due respect, I have investigated this and spent a significant amount of time trying to figure this out.  Sometimes you need a Band-Aid while you're trying to work on the bigger issue.

    This was sure helpful.  Thanks.

    Wednesday, January 20, 2016 2:45 PM
  • With all due respect, I have investigated this and spent a significant amount of time trying to figure this out.  Sometimes you need a Band-Aid while you're trying to work on the bigger issue.

    This was sure helpful.  Thanks.

    You didn't bother to mention that.

    In short, the answer is that you're doing this incorrectly. My assumption (since you didn't specify this either) is that you're using a logon script, which runs with user rights. Users can't change the time. If you want a bandaid, you'll need to use a startup script instead.


    Wednesday, January 20, 2016 2:55 PM
  • Agree with Mike; band-aiding with trying to run a script is not productive. Much better to fix the root cause.

    -- Bill Stewart [Bill_Stewart]

    Wednesday, January 20, 2016 3:13 PM
    Moderator
  • This vbs script is indeed within a startup, logon script that runs every time the user logs on and off the domain. (to map network resources, etc).  In my original thread I specified that it was an existing script and that I knew the script was working because I was receiving a drive mapping.  I just forgot to mention it was the logon script.

    So, to answer my question, is the syntax I have above, that I'm appending to my vbs logon script, correct?  If it is, then any thoughts on why it's not executing?

    Also, FYI, I have read where one of the possible root problems with this issue can be  DNS.  I ran dcdiag /test:dns on my domain controllers and they pass.

    Wednesday, January 20, 2016 3:26 PM
  • As Mike noted, standard users lack the privilege to change the system clock, so you can't do this in a logon script.

    You need to post domain configuration questions (including time synchronization) in the Directory Services forum.


    -- Bill Stewart [Bill_Stewart]

    Wednesday, January 20, 2016 3:48 PM
    Moderator
  • This vbs script is indeed within a startup, logon script that runs every time the user logs on and off the domain. (to map network resources, etc).

    Logon script != startup script.

    https://technet.microsoft.com/en-us/library/cc730773.aspx


    Wednesday, January 20, 2016 3:56 PM