meier3283 Posted March 5, 2010 Posted March 5, 2010 Does anyone have code already built, that will search all user profiles on a Windows system, and delete a certain file? (extend.dat) I'm new to autoit, and surfing the help file to get some ideas, but it doesn't seem to be as easy as I was hoping, unless I've missed a function somewhere. Any help is much appreciated, - David
99ojo Posted March 5, 2010 Posted March 5, 2010 (edited) Hi, you are a lucky guy and should play lotto this weekend. Tested on XP and 2000 for deleting all files in every users temp directory. Change it for your purpose: #include <array.au3> #include <file.au3> ;array holding default prof and service accounts and other excludes you want to, if you don't mind comment it out $ardefuser [4] = ["All Users", "Default User", "LocalService", "NetworkService"] ;get variable SystemDrive $sysdrive = EnvGet ("SystemDrive") ;get default profile folder ; if you have 64 Bit OS see helpfile RegRead to change code.... $profdir = StringReplace (RegRead ("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList", "ProfilesDirectory"), _ "%SystemDrive%", $sysdrive) ;get folders in Document and Settings and store in array $arfolders = _FileListToArray ($profdir, "*", 2) ;Loop over array For $i = 1 To UBound ($arfolders) - 1 ;if folder not found in default prof and service array then delete all in Temp Folder ;see remarks above if you don't mind, change line to ;FileDelete ($profdir & "\" & $arfolders [$i] & "\Local Settings\Temp\*.*") If _ArraySearch ($ardefuser, $arfolders [$i]) = - 1 Then FileDelete ($profdir & "\" & $arfolders [$i] & "\Local Settings\Temp\*.*") Next A clever search on forum: "delete file user" could have shorten your waiting time -> Code on 5 th position on search page. ;-)) Stefan Edited March 5, 2010 by 99ojo
kaotkbliss Posted March 5, 2010 Posted March 5, 2010 A clever search on forum: "delete file user" could have shorten your waiting time -> Code on 5 th position on search page. ;-))StefanHeh Heh, I know of at least a few times I would have liked to been able to "delete user"... 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy!
meier3283 Posted March 5, 2010 Author Posted March 5, 2010 Hi, you are a lucky guy and should play lotto this weekend. Tested on XP and 2000 for deleting all files in every users temp directory. Change it for your purpose: #include <array.au3> #include <file.au3> ;array holding default prof and service accounts and other excludes you want to, if you don't mind comment it out $ardefuser [4] = ["All Users", "Default User", "LocalService", "NetworkService"] ;get variable SystemDrive $sysdrive = EnvGet ("SystemDrive") ;get default profile folder ; if you have 64 Bit OS see helpfile RegRead to change code.... $profdir = StringReplace (RegRead ("HKLM\Software\Microsoft\Windows NT\CurrentVersion\ProfileList", "ProfilesDirectory"), _ "%SystemDrive%", $sysdrive) ;get folders in Document and Settings and store in array $arfolders = _FileListToArray ($profdir, "*", 2) ;Loop over array For $i = 1 To UBound ($arfolders) - 1 ;if folder not found in default prof and service array then delete all in Temp Folder ;see remarks above if you don't mind, change line to ;FileDelete ($profdir & "\" & $arfolders [$i] & "\Local Settings\Temp\*.*") If _ArraySearch ($ardefuser, $arfolders [$i]) = - 1 Then FileDelete ($profdir & "\" & $arfolders [$i] & "\Local Settings\Temp\*.*") Next A clever search on forum: "delete file user" could have shorten your waiting time -> Code on 5 th position on search page. ;-)) Stefan Thanks Stefan, I've always bragged, in the past, about being able to get anything out of google, however, the search on this forum wasn't giving it up without a fight. I searched high and low, without finding anything, prior to posted. ( I too hate people that don't help themselves ) I'll try harder next time. And thank you very much for your code, I'll put it to good use. - David
99ojo Posted March 5, 2010 Posted March 5, 2010 Hi,you are welcome.( I too hate people that don't help themselves ) I'll try harder next time.Never mind; I posted code I'll put it to good use.Hopefully
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