There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Type Mismatch: 'CDate'


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
absentmind's Avatar
Junior Member with 13 posts.
 
Join Date: Sep 2005
Experience: Intermediate
20-Oct-2005, 02:57 PM #1
Type Mismatch: 'CDate'
This script was meant to pull user profile data from remote computers, only problem is I can't get any time stamps due to this CDate mismatch error. Can anyone tell me what I'm doing wrong?

Code:
Const wbemImpersonationLevelImpersonate = 3
Const wbemAuthenticationLevelPktPrivacy = 6
Const ForAppending = 8

strUser=InputBox ("Domain Admin (domain\user)", "Get Profiles", default, 100, 100)
    If strUser="" Then
        WScript.Echo "Terminated due to missing parameter."
        WScript.Quit
    End If
strPass=InputBox ("Password for "&strUser&"", "Get Profiles", default, 100, 100)
    If strPass="" Then
        WScript.Echo "Terminated due to missing parameter."
        WScript.Quit
    End If
strComputer=InputBox ("Target Computer", "Get Profiles", default, 100, 100)
    If strComputer="" Then
        WScript.Echo "Terminated due to missing parameter."
        WScript.Quit
    End If
strNameSpace = "root\cimv2" 

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer _
    (strComputer, strNameSpace, strUser, strPass)

objSWbemServices.Security_.ImpersonationLevel = wbemImpersonationLevelImpersonate
objSWbemServices.Security_.AuthenticationLevel = wbemAuthenticationLevelPktPrivacy

Set colSWbemObjectSet = objSWbemServices.ExecQuery _
    ("Select * from Win32_NetworkLoginProfile")

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("profiles.txt", ForAppending)

objFile.WriteLine "*** " & strComputer & " ***"
objFile.WriteBlankLines(2)
For Each objItem in colSWbemObjectSet
    dtmWMIDate = objItem.AccountExpires
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objFile.WriteLine "Account Expires: " & strReturn
    objFile.WriteLine "Authorization Flags: " & objItem.AuthorizationFlags
    objFile.WriteLine "Bad Password Count: " & objItem.BadPasswordCount
    objFile.WriteLine "Caption: " & objItem.Caption
    objFile.WriteLine "CodePage: " & objItem.CodePage
    objFile.WriteLine "Comment: " & objItem.Comment
    objFile.WriteLine "Country Code: " & objItem.CountryCode
    objFile.WriteLine "Description: " & objItem.Description
    objFile.WriteLine "Flags: " & objItem.Flags
    objFile.WriteLine "Full Name: " & objItem.FullName
    objFile.WriteLine "Home Directory: " & objItem.HomeDirectory
    objFile.WriteLine "Home Directory Drive: " & objItem.HomeDirectoryDrive
    dtmWMIDate = objItem.LastLogoff
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objFile.WriteLine "Last Logoff: " & strReturn
    dtmWMIDate = objItem.LastLogon
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objFile.WriteLine "Last Logon: " & strReturn
    objFile.WriteLine "Logon Hours: " & objItem.LogonHours
    objFile.WriteLine "Logon Server: " & objItem.LogonServer
    objFile.WriteLine "Maximum Storage: " & objItem.MaximumStorage
    objFile.WriteLine "Name: " & objItem.Name
    objFile.WriteLine "Number Of Logons: " & objItem.NumberOfLogons
    objFile.WriteLine "Password Age: " & objItem.PasswordAge
    dtmWMIDate = objItem.PasswordExpires
    strReturn = WMIDateStringToDate(dtmWMIDate)
    objFile.WriteLine "Password Expires: " & strReturn
    objFile.WriteLine "Primary Group ID: " & objItem.PrimaryGroupId
    objFile.WriteLine "Privileges: " & objItem.Privileges
    objFile.WriteLine "Profile: " & objItem.Profile
    objFile.WriteLine "Script Path: " & objItem.ScriptPath
    objFile.WriteLine "Setting ID: " & objItem.SettingID
    objFile.WriteLine "Units Per Week: " & objItem.UnitsPerWeek
    objFile.WriteLine "User Comment: " & objItem.UserComment
    objFile.WriteLine "User Id: " & objItem.UserId
    objFile.WriteLine "User Type: " & objItem.UserType
    objFile.WriteLine "Workstations: " & objItem.Workstations
    objFile.WriteBlankLines(1)
Next

objFile.WriteLine "======================================="
objFile.WriteBlankLines(1)
objFile.Close 

Function WMIDateStringToDate(dtmStart)
    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




Call MsgBox ("Profile information collected.    ", 64, "Get Profiles")
aewarnick's Avatar
Senior Member with 839 posts.
 
Join Date: Sep 2002
30-Oct-2005, 06:26 PM #2
I'm not sure what CDate is, but it looks to me like you are trying to assign the return value of CDate to a function:
WMIDateStringToDate = CDate

You have some explaining to do.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 01:45 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.