Link to home
Start Free TrialLog in
Avatar of cyrens
cyrens

asked on

Retrieving Current date/time from Exchange Server

I want to generate a call report number, but would like to get the DATE and TIME (to use in creating the code number) from the server as opposed to local machines.

Any help would be appreciated.

JT
Avatar of vinnyd79
vinnyd79

You should be able to get the date and time from the server by using the net time command
net time \\servername
have you thought about setting up your server as a time source server and syncronizing the workstations to it?
following on from vinny,

do you use scripts to log on and map drives etc;?
net time \\servername /set /y

will update the workstations for you at each logon.

Avatar of cyrens

ASKER

I'm sorry. I wasn't clear in my question. I am writing VB code to retrieve the date and time from the server. I do not work on Exchange servers, just trying to write some code for an application.


jt
Then what about using the net time command from VB

' write batch file from vb to redirect output of net time to a temp file.

Open "C:\Tmptime.bat" for output as #1
Print #1,"net time \\servername > C:\tmptime"
Close #1

' execute the batch file
Shell("C:\Tmptime.bat")

' get rid of the batch file
Kill("C:\Tmptime.bat")

' open temp file and get the date and time.
Open "C:\tmptime" for input as #1
Line input #1,G$
MsgBox(G$)
Close #1

' kill tempfile or you can let it get overwritten on next use.
Kill("C:\tmptime")
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are working strictly with NT/2000 workstations and servers, why not use the Win32 API?  (See NetRemoteTOD)
Hello everyone.

We are cleaning up this topic area. This question is considered to be *outdated* and we would like you to move on with it.

Toward that end, we graciously request the following:

-----Askers-----

*Do NOT award points to me.

*Stay active in your question. If you asked this question and have not yet responded to the comments given by experts, please do so as soon as possible, even if it is just to say "I haven't been able to try that yet." If there are many comments, please address them all. If the suggestions given did not help, please give particulars such as error messages or other events that may have occurred. If the experts have asked questions, please respond to them to help them find a resolution to your issue. Please do not ignore them.

*If this issue remains unresolved, you may want to post a new, 0-point question here in this topic area with a link to this question in it to attract other experts.

*Award points for solutions. If one of the suggestions did work or if an expert put in a good effort toward resolving your issue, please award the points to that expert by clicking on the button above that expert's post that says "Accept comment as answer".

*If you have resolved this issue in another manner, please share it with us. We will refund your points and store the question in the database so others might get value from it.

*If you have given up on this issue, and prefer to delete it, you can request that, but the experts may choose to argue that they have worked hard to help you, and the moderator will make final determination if necessary.

*Most importantly, be fair in your grading. Please see guidelines for grading at
https://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp#3
If you give any grade less than an A without stating why, the grade will be changed upon request by the expert.

Thanks very much for being fair to our experts.



-----Experts-----

*Do not provide further support to this question unless the Asker responds that it is not yet resolved and wishes to continue to get help.

*If you truly believe that your answer is the best one that has been provided, please state which comment you made that you believe to be correct. If no one argues your comment, you will be awarded the points.

*If you would like to *vote* for another expert's comment, feel free to do so. Likewise, feel free to argue (nicely) any points that other experts make. We want everyone's input to be considered. Unless it is really unavoidable, vote only for one expert's response--it is quite a bit of work to split points, and many people come and go from the site and never see the "Points for" questions.

*Please don't thank the moderator for granting points to you. This only causes more email for the moderator, and I can personally attest to literally 100s of emails a day. Your thoughts are no less appreciated! We are experts too.

*Finally, if you ever question a moderator's determination, don't hesitate to do so right in the question in question. If you feel you want to voice your comment privately, email me at amp@experts-exchange.com.

Your input is extremely valuable and very much appreciated.

thank you
amp
community support moderator
Avatar of cyrens

ASKER

The project I was working on was cancelled so I never had a chance to try any of the options. I did close this out (or at least thought I did) some weeks ago. Still, the answer was acceptable.  Thanks vinny.
Thank YOU, Vinny!

amp
community support moderator