Hi Guys,

I'm new with dev in vbscript and I'm studying but risking to understand some scripts already ready and modify them for my use on the day.

I have a problem with the script below that I adapted to convert the Last user login's date / time.
This is showing error in the function call and I can't export the data to the CSV file with the correct date, could someone teach me how to do this function?

Code:
On Error Resume Next

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("\\MZ-FS-DW-029\D4003E231'\maq.txt", ForReading)

Do Until objTextFile.AtEndOfStream
    strComputer = objTextFile.Readline

 Set filesys = CreateObject("Scripting.FileSystemObject")
  If filesys.FileExists("\\MZ-FS-DW-029\D4003E231'\List.csv") Then 
   Set filetxt = filesys.OpenTextFile("\\MZ-FS-DW-029\D4003E231'\List.csv", ForAppending, True) 
  Else
   Set filetxt = filesys.OpenTextFile("\\MZ-FS-DW-029\D4003E231'\List.csv", ForWriting, True)
  End If

 strUser = "XXXXXX"
 strPassword = "proxxi88"

 Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
 
Set objWMIService = objwbemLocator.ConnectServer (strComputer, "\root\cimv2", strUser, strPassword) 
       objWMIService.Security.authenticationLevel = WbemAuthenticationLevelPktPrivacy
       
 Set colComputer = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
  For Each objComputer in colComputer
  UserID=objComputer.UserName
  NetBiosName=objComputer.Caption
  Domain= objComputer.Domain
 Next
 
  Set colPCDetail = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
 For Each objBios in colPCDetail
  Caption=objBIOS.Caption
  BuildNumber=objBIOS.BuildNumber  
 Next
 
  Set colLogon = objWMIService.ExecQuery("Select * from Win32_NetworkLoginProfile")
 For Each objLogon in colLogon
  CodFunc=objLogon.Caption 
  Name=objLogon.FullName
  dtmWMIDate = objItem.LastLogon 
  Login = WMIDateStringToDate(dtmWMIDate)	
 Next
 
Function WMIDateStringToDate(dtmWMIDate)  
    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 Function

 
 filetxt.WriteLine(NetBiosName & "," & UserID & "," & Caption & "," & BuildNumber & "," & CodFunc & "," & Name & "," & Login)
  
 filetxt.Close
 
 Loop

I need to collect some information (Hostname, User Logged, Last User, Operating System, Build and Version, Date / Time of Last Login and the date of installation of the Operating System.