Jump to content

How to delete *-Dirs ?


Recommended Posts

Heyho,

i want (as far as possible) all dirs and files in the user-temp-folder.

My Script:

$tempfiles = "C:\Dokumente und Einstellungen\"&@UserName&"\Lokale Einstellungen\Temp\*.*"
    FileDelete($tempfiles)
; doesnt work
    $tempfolders = "C:\Dokumente und Einstellungen\"&@UserName&"\Lokale Einstellungen\Temp\*"
    DirRemove($tempfolders, 1)

K... the first part, FileDelete, works fine... but i've some problems with the DirRemove...

I tried "temp", "temp\", "temp*", "temp*.*", and so on.. but its still not working.

Some Dirs in the Temp-Folder cannot deleted, i know - but there are still some Dummy-Folders (created by me) which are deleteable...

What do i wrong ?

Attention! English noob ^^

Link to comment
Share on other sites

If you actually want to remove just the temp files of the current user you can use @TempDir instead of that long string you were using in your post.

This example will delete all folders and files from the current users Temp folder as long as they are not in use.

#Include <File.au3>
#Include <Array.au3>

FileDelete(@TempDir & "\*.*")

$FileList=_FileListToArray(@TempDir, "*.", 2)

If IsArray($FileList) Then
    for $i = 1 to $FileList[0]
        MsgBox(0, "Folders", "Deleting " & $FileList[$i])
        DirRemove(@TempDir & "\" & $FileList($i)) 
    Next
EndIf
Link to comment
Share on other sites

I get an error, if i click on a button, assigned to that function...

In Scite:

$tempdir = "C:\Dokumente und Einstellungen\"&@Username&"\Lokale Einstellungen\Temp"

Y:\Programme\mops_installations.au3 (490) : ==> Error in expression.:

DirRemove($tempdir & "\" & $FileList($i), 1)

DirRemove(^ ERROR

... ?

Attention! English noob ^^

Link to comment
Share on other sites

I get an error, if i click on a button, assigned to that function...

In Scite:

$tempdir = "C:\Dokumente und Einstellungen\"&@Username&"\Lokale Einstellungen\Temp"

Y:\Programme\mops_installations.au3 (490) : ==> Error in expression.:

DirRemove($tempdir & "\" & $FileList($i), 1)

DirRemove(^ ERROR

... ?

I made a mistake, it should be $FileList[$i].
Link to comment
Share on other sites

Ahh,... :lmao:

Thanks :ph34r:

Maybe, but the error was that you had $TempDir but it should have been @TempDir.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

No, if u look on my code again, u see, that i've declared $TempDir manually...

Its a lil script for my company, that helps me to set up new workstations with programs, get some system informations, and so on... the last part is to clean up the installations (delete tempdirs, cleanup startmenu, and so on).

The Problem is, that - if i use @TempDir, i get on every time the tempdir of the logged-in user... if i've installed the programs under the Administrator-User, these Tempdirs will not deleted...

To test these functions, i declared the @TempDir for my currently logged-in user in $TempDir - if i compile the final version of the script, i will replace "&@UserName&" with "Administrator" ...

Attention! English noob ^^

Link to comment
Share on other sites

Hi,

ist das Problem noch akut?

Did you solve your problem?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

  • 2 years later...

Hi

I have problem with this

FileDelete(@TempDir & "/*.*")

$FileList=_FileListToArray(@TempDir, "*.", 2)

If IsArray($FileList) Then

for $i = 1 to $FileList[0]

MsgBox(0, "Folders", "Deleting " & $FileList[$i])

DirRemove(@TempDir & "\" & $FileList[$i])

Next

EndIf

sleep(2000)

MsgBox(0, "", "Clean Complit")

That work but show me anyone file in MsgBox and want accept

I dont wana see deleting progres i try cute this line MsgBox(0, "Folders", "Deleting " & $FileList[$i]) but then dont work

What can i do ??

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...