Actually, that is not working in VBSCript. Here is a script you can run on your computer that will return all the usernames by showing all the folders immediately under Documents and Settings and the date the folder was created:
Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder("C:\Documents and Settings\")
Sub ShowSubFolders(Folder)
For Each SubFolder In Folder.SubFolders
NewArray = Split(SubFolder.Path, "\")
strLogin = NewArray(2)
DateArray = Split(SubFolder.DateCreated, " ")
strCreate = CDate(DateArray(0))
WScript.Echo strLogin
WScript.Echo strCreate
End If
Next
End Sub
When I add the IF THEN statement on the WScript.Echo lines, this works and doesn't report the administrator folder...
Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder("C:\Documents and Settings\")
Sub ShowSubFolders(Folder)
For Each SubFolder In Folder.SubFolders
NewArray = Split(SubFolder.Path, "\")
strLogin = NewArray(2)
DateArray = Split(SubFolder.DateCreated, " ")
strCreate = CDate(DateArray(0))
If strLogin <> "administrator" Then
WScript.Echo strLogin
WScript.Echo strCreate
End If
Next
End Sub
... but when I use the following code, it not only does NOT get rid of the administrator and All Users folders, it reports both of them, even though the administrator folder is not reported in the second instance of the script...
Set FSO = CreateObject("Scripting.FileSystemObject")
ShowSubFolders FSO.GetFolder("C:\Documents and Settings\")
Sub ShowSubFolders(Folder)
For Each SubFolder In Folder.SubFolders
NewArray = Split(SubFolder.Path, "\")
strLogin = NewArray(2)
DateArray = Split(SubFolder.DateCreated, " ")
strCreate = CDate(DateArray(0))
If strLogin <> "administrator" Or strLogin <> "All Users" Then
WScript.Echo strLogin
WScript.Echo strCreate
End If
Next
End Sub
I think this is a limitation of VBScript. This works in
VB.NET, but it is not working here.
Does anyone else have any suggestions?
Thanks,
mmcdonal