CreateObject(“Scripting.FilesystemObject”) in VBScript

15 pts.
Tags:
HTA
VBS
VBScript
WMI
I currenly have a HTA that has alot of code. Part of the code displays a pop up message with the usersname to confirm we are working with the correct client. I Couldnt use WMI since all of our laptops block WMI quiries so I had to get inventive. All computers here have a default share. The script below

1. Pings the COMPUTERDNSNAME, If there is a reply 2. it reads the contents of the following \" & strComputer & "sic_c$Documents and Settings 3. If folder has been modifed in last 14 days it list the items in a popup box This acts as a conformation that the computername wasnt fatfigured, WMI would be alot better but not a option as they are not going to reconfigure the image firewall rules just for WMI to be active. I want to change the Last day to (100) since some of these PC dont have that folder writen to everyday.

So now my question. Is there anyway I can Exclude folder names from being listed? There are some accounts that show up in the list that I like to not show up. Such as NetworkService, XPRollout, All Users, Administrator ETC

SO is there a way i can EXCLUDE listing folders that = NetworkService, XPRollout, All Users, Administrator ETC

 

Here is a snippit of my code

Dim strComputer Dim WShell Dim fso, f, f1, fc, s, oLast Dim Msg

Sub Get_Login_Details    strComputer = txt_computer.value    if strComputer = "" Then    msgbox "Please enter a computer name or IP Address",vbOKOnly,"No Computer Name or IP Address"    Exit Sub    End If    If Ping(strComputer) = False Then    msgbox strComputer & " did not respond to ping. No action could be taken.",vbOkOnly, "Cannot continue script."    Exit Sub    End If      Set WShell = CreateObject("WScript.Shell")

oLast = DateAdd("d", -14, Now)

msgbox "Users who have logged on " & strComputer & " since " & oLast & ":" & vbCrLf & ShowFolderList("\" & strComputer & "sic_c$Documents and Settings") & vbcrlf & vbcrlf & vbcrlf & _            "Note: If no users are listed just insure you typed in the correct SIC#" & vbcrlf & vbcrlf

End Sub

function ShowFolderList(folderspec)    Set fso = CreateObject("Scripting.FileSystemObject")    Set f = fso.GetFolder(folderspec)    Set fc = f.SubFolders    For Each f1 In fc If DateValue(f1.DateLastModified) >= oLast Then       s = s & f1.name       s = s & VbCrLf End If    Next    ShowFolderList = s    set WShell = Nothing End Function



Software/Hardware used:
VBS VB script
ASKED: December 10, 2009  9:37 PM
UPDATED: May 10, 2011  9:14 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

You just need to add a condition to your ShowFolderList function to exclude them.

Your modified function, would look like this:

<pre>function ShowFolderList(folderspec)
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 In fc
If DateValue(f1.DateLastModified) >= oLast <b>and f1.name <> “NetworkService” and f1.name <> “XPRollout”</b> Then
s = s & f1.name
s = s & VbCrLf
End If
Next
ShowFolderList = s
set WShell = Nothing
End Function</pre>

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • JesseAGreen
    That Work Great!!! Thanks so much i would have never guess F1.name as im new to VBscripting. Is there anyway to sort the List so that the Last Modfied goes to the top?
    15 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following