Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Error 800A000D Cdate Problem

Status
Not open for further replies.

coolstorm6

IS-IT--Management
Jan 2, 2012
2
EG
Kindly i need your support when i run this Script on any target pc i gor this error 800A000D Cdate Problem


please Advice


Option Explicit
Dim objWMIService, objComputer, colComputer, colItems, objItem
Dim strLogonUser, strLogonUser1, strComputer, dtmWMIDate, strReturn, sDateAndTime

strComputer = "."
strComputer = InputBox("Enter Computer NAME HERE", _
"Find Logon User", strComputer)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * from Win32_NetworkLoginProfile")

For Each objItem in colItems
Wscript.Echo "Full Name: " & objItem.FullName
dtmWMIDate = objItem.LastLogoff
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logoff: " & strReturn
dtmWMIDate = objItem.LastLogon
strReturn = WMIDateStringToDate(dtmWMIDate)
Wscript.Echo "Last Logon: " & strReturn
Wscript.Echo "Name: " & objItem.Name
Wscript.Echo "Number Of Logons: " & objItem.NumberOfLogons

Next

Function WMIDateStringToDate(dtmWMIDate)
Dim sDateAndTime
If Not IsNull(dtmWMIDate) Then
WMIDateStringToDate = cdate(Mid(dtmWMIDate, 5, 2) & "/" & _
Mid(dtmWMIDate, 7, 2) & "/" & Left(dtmWMIDate, 4) _
& " " & Mid (dtmWMIDate, 9, 2) & ":" & _
Mid(dtmWMIDate, 11, 2) & ":" & Mid(dtmWMIDate, 13, 2))




End If
End Function
 
Code:
Wscript.Echo "Last Logoff: " & objItem.LastLogoff
Add this to an appropriate place in your code to see what the value of objItem.LastLogoff is before you pass it into your function.
 
i don't understand
can you please handle to me the script
 
What I posted above won't fix your script, but may give you a clue to what is wrong with it. Echo the value that you are trying to convert to a date, I don't think it is going to be what you expect. When I run your code, the value for last logoff is something like:
Code:
**************.******+***

Now you know why the date conversion is failing, but you need to figure out why LastLogoff is giving you such a value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top