|
-
Nov 11th, 2000, 02:37 PM
#1
Fanatic Member
Try this:
Code:
Function GetNetTime(PCName)
Dim TimeText As String
Dim NetTime As String
Dim NetTimeAsDate As Date
Dim ShellString As String
Dim i As Integer
ShellString = "command.com NET TIME \\" & PCName & " > c:\time.txt" 'get time
Shell ShellString
Open "c:\time.txt" For Input As #1
Line Input #1, TimeText 'read file
Close #1
i = InStr(1, TimeText, "is ", vbTextCompare)
TimeText = Mid(TimeText, i + 3)
i = InStr(1, TimeText, " ", vbTextCompare)
TimeText = Mid(TimeText, i + 1)
i = InStr(1, TimeText, "M", vbTextCompare)
TimeText = Left(TimeText, i - 2)
NetTime = Format(TimeText, "H:M AM/PM")
NetTimeAsDate = CDate(NetTime)
GetNetTime = NetTime 'for string (H:M AM/PM)
'GetNetTime = NetTimeAsDate 'for date(H:M:SS AM/PM) (Date Data Type)
End Function
It leaves an MS-DOS window open on my PC though, if that's a problem, you could use API's to close it (FindWindow & SendMessage) I can give you that code if you want
[Edited by gwdash on 11-11-2000 at 02:39 PM]
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
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
|