antmar904 Posted October 29, 2012 Share Posted October 29, 2012 hi all, i am new to autoit, i also tried searching the forum for help but i cant seem to get this to work. i am trying to run a startup script with a gpo that will delete all the content in all of the users temp dir in a win 7 env. here is what i have so far: #include <File.au3> #include <Array.au3> Local $UsersDir = _FileListToArray("C:\Users") DirRemove($UsersDir & "\AppData\Local\Temp\*.*") Link to comment Share on other sites More sharing options...
iamtheky Posted October 29, 2012 Share Posted October 29, 2012 (edited) filelisttoarray returns an array, you would need to loop through that like: edit* put the arraydisplay in so you can see what you are working through #Include <File.au3> #Include <Array.au3> $users = _FileListToArray("C:users" , "*" , 2) _ArrayDisplay($users) for $i = 1 to $users[0] filedelete("c:users" & $users[$i] & "appdatalocaltemp*.*") next Edited October 29, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
antmar904 Posted October 29, 2012 Author Share Posted October 29, 2012 ty boththose but that did not work, after running it i still see files and folders in the users temp dir. Link to comment Share on other sites More sharing options...
iamtheky Posted October 29, 2012 Share Posted October 29, 2012 in session you probably have all sorts of fun ACL and attribute issues. Dump the file list of the temp directory and iterate through that and you should be able to clean up all the files that are not in use ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
antmar904 Posted October 29, 2012 Author Share Posted October 29, 2012 (edited) explain please?im not sure what you mean"Dump the file list of the temp directory and iterate through that and you should be able to clean up all the files that are not in use" Edited October 29, 2012 by antmar904 Link to comment Share on other sites More sharing options...
iamtheky Posted October 29, 2012 Share Posted October 29, 2012 (edited) just throwing the contents of each temp file to an array, and deleting them individually. In my experience, that lets the locked files error out individually, rather than bombing your entire wildcarded filedelete. #Include <File.au3> #Include <Array.au3> $users = _FileListToArray("C:users" , "*" , 2) ;~ _ArrayDisplay($users) for $i = 1 to $users[0] $tempfiles = _FileListToArray("c:users" & $users[$i] & "appdatalocaltemp") If isarray($Tempfiles) Then ;~ _ArrayDisplay($tempfiles) for $j = $tempfiles[0] to 1 step -1 filedelete("c:users" & $users[$i] & "appdatalocaltemp" & $Tempfiles[$j]) next EndIf $tempfiles = "" next Edited October 29, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
BrewManNH Posted October 29, 2012 Share Posted October 29, 2012 If you want to delete the contents of all the Temp folders, you can just do a DirRemove on the Temp folder itself. As soon as the user logs back on, the folder gets recreated without any issues. It's a LOT easier than trying to delete each file and/or folder from the Temp folder. Don't forget to set the Recurse flag on DirRemove so that it deletes everything. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
antmar904 Posted October 29, 2012 Author Share Posted October 29, 2012 ok in understand, will this also delete folders as well or just files? thank you for your help. Link to comment Share on other sites More sharing options...
BrewManNH Posted October 29, 2012 Share Posted October 29, 2012 If you use DirRemove with the recurse flag set, it deletes the Temp folder, all the files in it, all the folders under it, and all the files in those folders as well. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
antmar904 Posted October 29, 2012 Author Share Posted October 29, 2012 that would probably be the easiest thing to do. so it would look something like this? #Include <File.au3> #Include <Array.au3> $users = _FileListToArray("C:users" , "*" , 2) _ArrayDisplay($users) for $i = 1 to $users[0] dirremove("c:users" & $users[$i] & "appdatalocaltemp" ,1) next Link to comment Share on other sites More sharing options...
BrewManNH Posted October 29, 2012 Share Posted October 29, 2012 You can't delete your own Temp folder while you're logged in, the folder and probably several files are going to be in use. Where I work, we delete the Temp folder as the user logs out so that it gets rid of all the crap they've accumulated during their session. Sometimes it works, sometimes there's still a file in use that prevents it, but it works 99% of the time. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
antmar904 Posted October 29, 2012 Author Share Posted October 29, 2012 i understand that, that is why i am running it as a startup GPO. how does the above code look, correct? Link to comment Share on other sites More sharing options...
BrewManNH Posted October 29, 2012 Share Posted October 29, 2012 In case you're wondering what my last post was referring to, there's a post that isn't there any longer that I was responding to. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
iamtheky Posted October 29, 2012 Share Posted October 29, 2012 (edited) yeah i was editing and blanked it in err, then subsequently deleted it rather than retype all that, i suppose you were replying in the duration. In my additional playing in the mean, DirRemove with recurse works just as well in session as any other mechanism, minus the objects with attribute issues and those in use, naturally. Edited October 29, 2012 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Nadir Posted April 9, 2016 Share Posted April 9, 2016 What Can I Type In $users #antmar904 Please Help Me Link to comment Share on other sites More sharing options...
BrewManNH Posted April 10, 2016 Share Posted April 10, 2016 Why are you posting in a thread nearly 4 years old and then asking a question no one could possibly answer because you gave no information? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
iamtheky Posted April 10, 2016 Share Posted April 10, 2016 And why would you address the one person who isnt here? ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Nadir Posted April 10, 2016 Share Posted April 10, 2016 Please Tell Me How I Can I Do It Please BrewManNH And iamtheky Link to comment Share on other sites More sharing options...
guinness Posted April 10, 2016 Share Posted April 10, 2016 31 minutes ago, Nadir said: Please Tell Me How I Can I Do It Please BrewManNH And iamtheky Don't bump posts you don't own Don't beg people to help you Learn about Forum etiquette Do not reply to this message UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Nadir Posted April 10, 2016 Share Posted April 10, 2016 11 hours ago, Nadir said: What Can I Type In $users Please Help Me Please Tell Me How I Can I Do It Please Link to comment Share on other sites More sharing options...
Recommended Posts