Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-22-2008, 02:51 PM   #1 (permalink)
 
Ultra Techie

Join Date: Jun 2006

Posts: 938

King X13 is on a distinguished road

Send a message via AIM to King X13
Default Anyone know .vbs?

Ok so i have a script that looks like this

Const LocalDocumentsFolder = "C:\Documents and Settings\"

set objFSO = createobject("Scripting.FileSystemObject")
set objFolder = objFSO.GetFolder(localdocumentsfolder)

on error resume next

for each fldr in objFolder.SubFolders
if not isexception(fldr.name) then
objFSO.DeleteFolder fldr.path, True
end if
next

Function isException(byval foldername)
select case foldername
case "All Users"
isException = True
case "Default User"
isException = True
case "Administrator"
isException = True
case Else
isException = False
End Select
End Function

now that works fine but i also want to add to the script a section like:


for each fldr in objFolder.SubFolders
if DateDiff("d", oFile.DateModified, Now) >= 60 then
objFSO.DeleteFolder fldr.path, True
end if
next


so that it doesnt delete my administrator folder and doesnt delete folders under 60 days old. when i put 1 under the other i dont get exactly my desired results and was hoping someone could help me clean it up and make it work.
King X13 is offline  
Old 04-28-2008, 06:24 PM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: /usr/root/mn/us

Posts: 1,121

bla!! is on a distinguished road

Default Re: Anyone know .vbs?

What exactly do you mean by put 1 under the other, adn what results are you missing?

One thing I see right of the bat is you have oFile.dateModified being used in your DateDiff, but oFile isnt set anywhere. As well, the property of the last modified date of a file is .DateLastModified
__________________
<br>
Its a frigging Laptop, not a Labtop!!!!
bla!! is offline  
 
Closed Thread

Thread Tools
Display Modes

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 On
Refbacks are On