Jump to content

Is there a autoit version of this VB script ?


Recommended Posts

Hello,

I'm using this script at a customer of mine to cleanup locale user profiles :

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 "LocalService"

isException = True

case "NetworkService"

isException = True

case "Administrator"

isException = True

case "Nood"

isException = True

case Else

isException = False

End Select

End Function

Is there an Autoit version for this. Would be nice if the exceptions could be set in a ini file.

John

Link to post
Share on other sites

Without knowing VB script, it does not look to hard to recreate

I'll start you off...

Global Const $LocalDocumentsFolder = "C:Documents and Settings"

$objFSO = ObjCreate("Scripting.FileSystemObject")

If Not IsObj ($objFSO) Then
MsgBox(0,"","Error")
Exit
EndIf

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to post
Share on other sites

I don't know VB script either, but perhaps the IsException function could be rewritten like this

Func _$isException($foldername)
    Switch $foldername
        Case "All Users"
            $isException = True
        Case "Default User"
            $isException = True
        Case "LocalService"
            $isException = True
        Case "NetworkService"
            $isException = True
        Case "Administrator"
            $isException = True
        Case "Nood"
            $isException = True
        Case Else
            $isException = False
    EndSwitch
EndFunc

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Link to post
Share on other sites

that original VB script looks like a recursive nightmare ... and won't do anything but eat memory. Why are you calling your function ... inside the function?

Which function are you referring to? isException? That's how to return the function in vbscript.

edit:

msgbox isEven(7)
msgbox isEven(10542348)

Function isEven(varNum)
    if varNum mod 2 = 0 Then
        isEven = True
    else
        isEven = False
    end if
End Function
Edited by spudw2k
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...