Jump to content

Delete temp files


zac23
 Share

Recommended Posts

Hey im wrighting a script with a gui, ive got the gui to work but i cant figure out how to delete files from other perples user profiles without spesifying a user name to look at and not looking in the currrent user that is logged in, im sure im missing something simple any ideas?

Edited by zac23
Link to comment
Share on other sites

i got this so far but it dosent work need to do something with the "not' lol

func deletetmpfiles()

if FileExists("D:\userdata\*\Temp") not @UserName Then

FileDelete("D:\userdata\*\Temp")

Else

MsgBox(1,"DelTemp","temp Dose not exist!")

EndIf

EndFunc

Link to comment
Share on other sites

i got this so far but it dosent work need to do something with the "not' lol

func deletetmpfiles()

if FileExists("D:\userdata\*\Temp") not @UserName Then

FileDelete("D:\userdata\*\Temp")

Else

MsgBox(1,"DelTemp","temp Dose not exist!")

EndIf

EndFunc

Please consider working thru this tutorial on using AutoIt

http://www.autoitscript.com/forum/index.ph...st&p=607559

Also, it is not a good idea to delete every temp file - it might be best to only delete "old" ones.

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

But even a person that has logged off may have a temp file that is part of a document that can be recovered.

there meant to save anything to a network drive that also keeps a record of deleted stuf for a while

we go through and delete all of them anyway our operating system recreates anything important on logon too

im just trying to increase speed at which we speed up the pcs

Link to comment
Share on other sites

I'm not sure what OS you're using, but this (based upon the help file example for "_FileListToArray") might be a good way to start:

#Include <File.au3>
#Include <Array.au3>
$FileList=_FileListToArray("C:\Documents and Settings\","*",2)
If @Error=1 Then
    MsgBox (0,"","No Files\Folders Found.")
    Exit
EndIf
_ArrayDisplay($FileList,"$FileList")
For $x = 1 to $FileList[0]
    Switch $FileList[$x]
        Case "LocalService", "NetworkService", @UserName; users to ignore
        Case Else; users to process
            MsgBox(1,"","Deleting temp files for: " & $FileList[$x])
    EndSwitch
Next

That example is tuned for my Windows XP Pro SP3...

Edit: added @UserName to switch statement

Edited by Spiff59
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...