Sign in to follow this  
Followers 0
jslegers

Is there a autoit version of this VB script ?

8 posts in this topic

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

Share this post


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.

Share this post


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.

Share this post


Link to post
Share on other sites

Thanks for the tips I will try it.

Share this post


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?


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

*facepalm* Right ... it's been a while since I had to do anything with VB. Sorry about that.


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


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
Sign in to follow this  
Followers 0