|
-
May 16th, 2001, 09:18 PM
#1
Server date and time
Hi! I just wanted to ask if there is a way to access the server date and time when you are in a client computer. Are there any existing function that I could use in order to do this? Thanks. Hope you can help me.
-
May 16th, 2001, 11:23 PM
#2
Re: Server date and time
You could use the "NET TIME" DOS command by wrapping it in a batch file and using it through VB, i.e.option Explicit
private Sub Command1_Click()
Dim iFile as Integer
Dim sResults as string
iFile = FreeFile
Open "C:\~Temp.bat" for Output as iFile
print #iFile, "NET time " & txtServerName & " > C:\~Results.txt";
Close iFile
If len(Dir("C:\~Results.txt")) then Kill "C:\~Results.txt"
Caption = "Checking server """ & txtServerName & """..."
Shell "C:\~Temp.bat", vbHide
While len(Dir("C:\~Results.txt")) = 0
DoEvents
Wend
While FileLen("C:\~Results.txt") = 0
DoEvents
Wend
iFile = FreeFile
Open "C:\~Results.txt" for input as iFile
sResults = input(LOF(iFile), iFile)
Close iFile
If InStr(LCase(sResults), "incorrect") Or InStr(LCase(sResults), "error ") then
Caption = "UnKnown."
else
sResults = mid(sResults, InStr(sResults, " is ") + 4)
sResults = Left(sResults, InStr(sResults, vbCrLf) - 1)
Caption = sResults
End If
End Sub
Aaron Young
Senior Programmer Analyst
[email protected]
Certified AllExperts Expert: http://www.allexperts.com/displayExp...p?Expert=11884
-
May 17th, 2001, 02:14 AM
#3
Re: Server date and time
It is great to read from you again!
Best regards,
Cesare Imperiali
Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|