Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sync WINDOWS TIME now, CODE OR CMD.EXE WHATEVER WORKS!

Posted on 2009-05-05
6
Medium Priority
?
1,871 Views
Last Modified: 2013-12-23
Hi,

i need some small code to sync the WINDOWS TIME now....
CODE or this wich does not work IMEDIATLY.....

w32tm /config /manualpeerlist:time.windows.com /update


The time sync is needed so i can test for the correct time,
and shutdown the pc.
If a user adjust the windows clock.......... shit...... then the time
server needs to be synced.

whatever works......
i only need to sync the windowstime.....WITHOUT a delay...
whatever works........


code or command.......... whatever works.

thanks.

0
Comment
Question by:marco_coder
[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
  • 4
  • 2
6 Comments
 
LVL 40

Expert Comment

by:evilrix
ID: 24303521
Assuming you have Windows configured to get its time from a time server (the default setting as far as I know)...

http://support.microsoft.com/kb/314054

To reset the local computers' time against the time server, run the following command on all the computers except the time server:

w32tm /resync /rediscover
0
 

Author Comment

by:marco_coder
ID: 24329954
I want to use it from c/c++

HIDEWINDOW("CMD") // NOT IMPORTANT.


system("w32tm /resync /rediscover");

on my system i get a error:
Sending resync command to local computer...
The computer did not resync because no time data was available.


I need this so my SERVICE.EXE can sneaky send time updates.
My program is a CYBER PARRENT control..... and i the users adjust the windows clock........
the program is useless so i am trying to find a way to sync the windows clock....


Thanks.




0
 
LVL 40

Expert Comment

by:evilrix
ID: 24330101
An alternative you could try is:

NET TIME /SET

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 40

Expert Comment

by:evilrix
ID: 24330165
Or implement your own NTP client (it's not too hard) and use http://www.pool.ntp.org/ to get the time.

You can use this library to get you started

http://www.hotscripts.com/listing/hs-ntp-c-source-library/

"HS NTP C Source Library

HS NTP is a software library in C (supplied with full source code) which implements the client side of Network Time Protocol (NTP) over UDP socket layer according to RFC1769 and RFC1305. HS NTP Library allows a user application to synchronise local system time to remote NTP server time. First user application calls HS NTP initialisation function supplying pointers to callback functions in user code for timer management and for reporting NTP events to user. To obtain time difference between local system and remote NTP server, the user application calls HsNtpGetTime function, specifying NTP server name or IP address and source UDP port to use. HS NTP library then resolves the server name, formats and sends NTP time request packet according to RFC1305 and RFC1769 standard. Once HS NTP has received NTP time reply from NTP server it analyses the reply and reports the resulting time difference to user application via callback function"
0
 

Author Comment

by:marco_coder
ID: 24334717
Thanks,

I am just looking for a simple solution

c:\NET TIME /SET
Could not locate a time-server.

0
 
LVL 40

Accepted Solution

by:
evilrix earned 810 total points
ID: 24334728
>> I am just looking for a simple solution
Well, I think we've ruled that out :)

Implementing your own ntp client (using the code above) is going to be relatively simple (since the hard work has already been done). The problem with the command line approach is it relies on the Windows time service being configured correctly. Since you are looking to implement this as a security feature you can't really rely on this. Secure and simple rarely go hand in hand I'm afraid.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

The Need In an Active Directory enviroment, the PDC emulator provide time synchronization for the domain. This is important since Active Directory uses Kerberos for authentication.  By default, if the time difference between systems is off by more …
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

610 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