Solved

Retrieving Current date/time from Exchange Server

Posted on 2001-09-12
9
235 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:cyrens
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6478224
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?
0
 

Expert Comment

by:joe_lafferty
ID: 6479201
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.

0
 

Author Comment

by:cyrens
ID: 6480800
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
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 6480831
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")
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 28

Accepted Solution

by:
vinnyd79 earned 50 total points
ID: 6480865
In the above example you can hide the dos window by shelling to the batch file and using vbhide like so:

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

You can also shell command interpretor to get output of net time,but then you have to check the OS so you know whether to shell to C:\command.com or C:\winnt\system32\cmd.exe.

If you want to try that this is for winnt:
Dim A
A = Shell("c:\winnt\system32\cmd.exe /c net time \\servername > C:\tmptime", vbHide)

win98:

Dim A
A = Shell("c:\command.com /c net time \\servername > C:\tmptime", vbHide)

Then you can open the temp file to get your data just like above example:

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



Hope this helps


0
 
LVL 16

Expert Comment

by:Neo_mvps
ID: 6482553
If you are working strictly with NT/2000 workstations and servers, why not use the Win32 API?  (See NetRemoteTOD)
0
 

Expert Comment

by:amp072397
ID: 6714118
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
http://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
0
 

Author Comment

by:cyrens
ID: 6714243
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.
0
 

Expert Comment

by:amp072397
ID: 6714461
Thank YOU, Vinny!

amp
community support moderator
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now