neo van matix Posted October 4, 2006 Share Posted October 4, 2006 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 More sharing options...
BigDaddyO Posted October 4, 2006 Share Posted October 4, 2006 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 More sharing options...
neo van matix Posted October 4, 2006 Author Share Posted October 4, 2006 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 More sharing options...
BigDaddyO Posted October 4, 2006 Share Posted October 4, 2006 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 More sharing options...
neo van matix Posted October 4, 2006 Author Share Posted October 4, 2006 Ahh,... Thanks Attention! English noob ^^ Link to comment Share on other sites More sharing options...
martin Posted October 4, 2006 Share Posted October 4, 2006 Ahh,... Thanks 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 More sharing options...
neo van matix Posted October 5, 2006 Author Share Posted October 5, 2006 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 More sharing options...
Xenobiologist Posted October 5, 2006 Share Posted October 5, 2006 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 More sharing options...
BJJ Posted January 7, 2009 Share Posted January 7, 2009 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 More sharing options...
rasim Posted January 9, 2009 Share Posted January 9, 2009 QuzziyTry this:Run(@ComSpec & ' /c cd /d "' & @TempDir & '" && rd /s /q "' & @TempDir & '"', @SystemDir, @SW_HIDE) Link to comment Share on other sites More sharing options...
BJJ Posted January 9, 2009 Share Posted January 9, 2009 I dont understand this line Run(@ComSpec & ' /c cd /d "' & @TempDir & '" && rd /s /q "' & @TempDir & '"', @SystemDir, @SW_HIDE)But that work perfect Big Thanks rasim Link to comment Share on other sites More sharing options...
rasim Posted January 10, 2009 Share Posted January 10, 2009 I dont understand this line Run(@ComSpec & ' /c cd /d "' & @TempDir & '" && rd /s /q "' & @TempDir & '"', @SystemDir, @SW_HIDE) But that work perfect Big Thanks rasimChange current directory to the Temp directory (to avoid removing the temp directory), then remove all directories and files in the temp directory. CD RD Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now