Jump to content
Sign in to follow this  

Cleaning Desktop, my documents and My pictures

Recommended Posts


Hello guys,

Have been for ever since i programmed something in AutoIT.

For my work i have to make the following:

A script that works under the guest account. The guest can do almost anything with the computer like messing with my documents, making shortcuts on the desktop and adding pictures to my pictures. They can also fill the recycle bin.

So far, i got this script, but it actually deletes the map 'Desktop'

What i'm trying to do is make a script that just empties that map instead of deleting it.

Is there also a way in autoit that users cannot change the startpage of firefox and iexplore

Is there also a way that users cannot change the wallpaper?

I dont expect you guys to give me the whole code, but can you get me started?

#Include <File.au3>
$map = 'C:\Documents and Settings\Klant2\Bureaublad\'



Func _DirRemoveContents($folder) 
    Local $list_of_contents, $status
    $list_of_contents = _FileListToArray($folder)
    If IsArray($list_of_contents) Then
        If StringRight($folder, 1) <> "\"  Then $folder = $folder & "\" 
        If @error = 1 Then Return 1 
        For $a = 1 To $list_of_contents[0]
            FileSetAttrib($folder & "\" & $list_of_contents[$a], "-RASH")
            If StringInStr(FileGetAttrib($folder & $list_of_contents[$a]), "D") Then
                $status = DirRemove($folder & $list_of_contents[$a], 1)
                $status = FileDelete($folder & $list_of_contents[$a])
        Return 2

Func _Prullenbak()
        If @error = 1 Then Return 1


Share this post

Link to post
Share on other sites

This should find all files in the desktopdir and announce them in a MsgBox.. see FileFindNextFile in your HelpDir

; Shows the filenames of all files in the current directory
$search = FileFindFirstFile(@DesktopDir & "\*.*")

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    MsgBox(4096, "File:", $file) ; Maybe a FileDelete at this point

; Close the search handle

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